Skip to content

Commit

Permalink
Update renderNormalizerOutputOOIs.js (#3142)
Browse files Browse the repository at this point in the history
Co-authored-by: ammar92 <[email protected]>
Co-authored-by: Jeroen Dekkers <[email protected]>
  • Loading branch information
3 people authored Jul 2, 2024
1 parent a3c3b6a commit 8bfe9fd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rocky/assets/js/renderNormalizerOutputOOIs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { language, organization_code } from "./utils.js";
const buttons = document.querySelectorAll(
".expando-button.normalizer-list-table-row",
);
const asyncoffset = 5; // time (in seconds) to allow for the database to actually save the OOIs

buttons.forEach((button) => {
const raw_task_id = button.closest("tr").getAttribute("data-task-id");
Expand Down Expand Up @@ -80,10 +81,16 @@ buttons.forEach((button) => {
"/" +
escapeHTMLEntities(encodeURIComponent(organization_code));
let object_list = "";

// set the observed at time a fews seconds into the future, as the job finish time is not the same as the ooi-creation time. Due to async reasons the object might be a bit slow.
data["timestamp"] = Date.parse(data["valid_time"] + "Z");
data["valid_time_async"] = new Date(
data["timestamp"] + asyncoffset * 1000,
)
.toISOString()
.substring(0, 19); // strip milliseconds
// Build HTML snippet for every yielded object.
data["oois"].forEach((object) => {
object_list += `<li><a href='${url}/objects/detail/?observed_at=${data["valid_time"]}&ooi_id=${escapeHTMLEntities(encodeURIComponent(object))}'>${escapeHTMLEntities(object)}</a></li>`;
object_list += `<li><a href='${url}/objects/detail/?observed_at=${data["valid_time_async"]}&ooi_id=${escapeHTMLEntities(encodeURIComponent(object))}'>${escapeHTMLEntities(object)}</a></li>`;
});
element.innerHTML = `<ul>${object_list}</ul>`;
} else {
Expand Down

0 comments on commit 8bfe9fd

Please sign in to comment.