15 lines
835 B
PHP
15 lines
835 B
PHP
<?php
|
|
require_once __DIR__.'/job.class.php';
|
|
class Results {
|
|
public static function manifest(array $job): ?array {
|
|
$path=Job::directory($job).'/artifacts/index.json'; if(!is_file($path)) return null;
|
|
$data=json_decode((string)file_get_contents($path),true); return is_array($data)&&is_array($data['datasets']??null)?$data:null;
|
|
}
|
|
public static function dataset(array $job,string $id): ?array {
|
|
if(!preg_match('/^[a-f0-9]{32}$/',$id)) return null;
|
|
$manifest=self::manifest($job); if(!$manifest||!in_array($id,array_column($manifest['datasets'],'id'),true)) return null;
|
|
$path=Job::directory($job).'/artifacts/datasets/'.$id.'/index.json'; if(!is_file($path)) return null;
|
|
$index=json_decode((string)file_get_contents($path),true); return is_array($index)?$index:null;
|
|
}
|
|
}
|