Provide metadata in the log api

This commit is contained in:
Graham Christensen 2018-02-21 22:42:35 -05:00
parent aba3ad04e5
commit 10ecd201b3
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C

View file

@ -42,7 +42,19 @@ if ($handle = opendir($req)) {
} }
if (is_file($req . '/' . $entry)) { if (is_file($req . '/' . $entry)) {
$d['attempts'][$entry] = [ "log_url" => "$serve_root/$entry" ]; if (substr($entry, -strlen(".metadata.json"),strlen(".metadata.json")) == ".metadata.json") {
$metadata = json_decode(file_get_contents($req . '/' . $entry), JSON_OBJECT_AS_ARRAY);
$attempt = $metadata['attempt_id'];
if (!isset($d['attempts'][$attempt])) {
$d['attempts'][$attempt] = [];
}
$d['attempts'][$attempt]['metadata'] = $metadata;
} else {
if (!isset($d['attempts'][$entry])) {
$d['attempts'][$entry] = [];
}
$d['attempts'][$entry]['log_url'] = "$serve_root/$entry";
}
} }
} }
} }