fix(tests): replace updated_at (doesn't exist) with real timestamps
Some checks failed
Aegis CI / lint-and-test (push) Has been cancelled
Some checks failed
Aegis CI / lint-and-test (push) Has been cancelled
TestsPage 'Updated' column: compute lastActivityDate() from the most recent available timestamp — blue_validated_at > red_validated_at > blue_work_started_at > blue_started_at > red_started_at > created_at. Also fixes the sort-by-updated_at case. ValidatedTestsPage 'Validated' column: use blue_validated_at (when Blue Lead approved) falling back to red_validated_at. Fixes both the display and the default sort-by-validated.
This commit is contained in:
@@ -224,8 +224,8 @@ export default function TestsPage() {
|
||||
bv = b.created_at || "";
|
||||
break;
|
||||
case "updated_at":
|
||||
av = a.updated_at || "";
|
||||
bv = b.updated_at || "";
|
||||
av = lastActivityDate(a) || "";
|
||||
bv = lastActivityDate(b) || "";
|
||||
break;
|
||||
case "waiting_time": {
|
||||
const aIsBlue = a.state === "blue_evaluating";
|
||||
@@ -281,6 +281,23 @@ export default function TestsPage() {
|
||||
});
|
||||
};
|
||||
|
||||
// updated_at doesn't exist in DB — derive "last activity" from the most
|
||||
// recent non-null timestamp available on the test record
|
||||
const lastActivityDate = (t: import("../types/models").Test): string | null => {
|
||||
const candidates = [
|
||||
t.blue_validated_at,
|
||||
t.red_validated_at,
|
||||
(t as any).blue_work_started_at,
|
||||
(t as any).blue_started_at,
|
||||
(t as any).red_started_at,
|
||||
t.created_at,
|
||||
].filter(Boolean) as string[];
|
||||
if (!candidates.length) return null;
|
||||
return candidates.reduce((latest, d) =>
|
||||
new Date(d) > new Date(latest) ? d : latest
|
||||
);
|
||||
};
|
||||
|
||||
// ── My tasks label ────────────────────────────────────────────────
|
||||
const myTasksLabel = useMemo(() => {
|
||||
if (!user) return "My Tasks";
|
||||
@@ -594,7 +611,7 @@ export default function TestsPage() {
|
||||
{formatDate(test.created_at)}
|
||||
</td>
|
||||
<td className="py-3 px-4 text-gray-400 text-xs whitespace-nowrap">
|
||||
{formatDate(test.updated_at)}
|
||||
{formatDate(lastActivityDate(test))}
|
||||
</td>
|
||||
<td className="py-3 pl-4">
|
||||
<button
|
||||
|
||||
@@ -72,7 +72,7 @@ export default function ValidatedTestsPage() {
|
||||
| "attack_success"
|
||||
| "detection_result"
|
||||
| "created_at"
|
||||
| "updated_at";
|
||||
| "updated_at"; // maps to blue_validated_at
|
||||
|
||||
const [sortKey, setSortKey] = useState<SortKey>("updated_at");
|
||||
const [sortDir, setSortDir] = useState<"asc" | "desc">("desc");
|
||||
@@ -145,8 +145,9 @@ export default function ValidatedTestsPage() {
|
||||
bv = b.created_at || "";
|
||||
break;
|
||||
case "updated_at":
|
||||
av = a.updated_at || "";
|
||||
bv = b.updated_at || "";
|
||||
// "Validated" column = when Blue Lead validated (last validation step)
|
||||
av = a.blue_validated_at || a.red_validated_at || a.created_at || "";
|
||||
bv = b.blue_validated_at || b.red_validated_at || b.created_at || "";
|
||||
break;
|
||||
}
|
||||
const cmp = av < bv ? -1 : av > bv ? 1 : 0;
|
||||
@@ -280,7 +281,7 @@ export default function ValidatedTestsPage() {
|
||||
{formatDate(test.created_at)}
|
||||
</td>
|
||||
<td className="px-4 py-3 text-xs text-gray-400 whitespace-nowrap">
|
||||
{formatDate(test.updated_at)}
|
||||
{formatDate(test.blue_validated_at || test.red_validated_at)}
|
||||
</td>
|
||||
<td className="px-4 py-3">
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user