From 1036b469ad2e30e3af35dca7c9b33ee052808e0c Mon Sep 17 00:00:00 2001 From: Philip Jackson Date: Fri, 29 Jul 2022 16:58:20 +0100 Subject: [PATCH 1/2] fix: split annotation sessions by sessionStart/sessionEnd --- src/wrappers/AuditWrapper.tsx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/wrappers/AuditWrapper.tsx b/src/wrappers/AuditWrapper.tsx index c2cd8221..775a684f 100644 --- a/src/wrappers/AuditWrapper.tsx +++ b/src/wrappers/AuditWrapper.tsx @@ -7,6 +7,7 @@ import { DominateStore } from "@/store"; import { useAuth, useStore } from "@/hooks"; import { setStateIfMounted } from "@/helpers"; import { ProductNavbarData } from "@/components"; +import { timestampInSeconds } from "@sentry/utils"; const logger = console; @@ -142,9 +143,28 @@ export const AuditWrapper = ({ if (!auth || !collectionUid || sessions === null) return null; + // annotation sessions contain all the actions for a given image/user; actual sessions + // are delimited by sessionStart and sessionEnd, so split on those here: + const actualSessions = sessions + .map((session) => { + const splitSessions: AnnotationSession[] = []; + for (const action of session.audit) { + if (action.method === "sessionStart") { + const newSession = session; + newSession.timestamp = action.timestamp; + newSession.audit = [action]; + splitSessions.push(newSession); + } else { + splitSessions[splitSessions.length - 1].audit.push(action); + } + } + return splitSessions; + }) + .flat(); + return ( From 1a5ebad2be0724d93ff1ea097068e7879c48beca Mon Sep 17 00:00:00 2001 From: Philip Jackson Date: Fri, 29 Jul 2022 17:58:00 +0100 Subject: [PATCH 2/2] fix: mix annotation sessions with other project audit actions --- src/wrappers/AuditWrapper.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/wrappers/AuditWrapper.tsx b/src/wrappers/AuditWrapper.tsx index 775a684f..ee12ba20 100644 --- a/src/wrappers/AuditWrapper.tsx +++ b/src/wrappers/AuditWrapper.tsx @@ -143,6 +143,8 @@ export const AuditWrapper = ({ if (!auth || !collectionUid || sessions === null) return null; + const projectAuditActions = storeInstance.getProjectLevelAudit(); + // annotation sessions contain all the actions for a given image/user; actual sessions // are delimited by sessionStart and sessionEnd, so split on those here: const actualSessions = sessions @@ -160,7 +162,20 @@ export const AuditWrapper = ({ } return splitSessions; }) - .flat(); + .flat() + // convert annotation sessions into the same format as other project audit actions: + .map((session) => ({ + action: { + type: "annotate", + imageName: session.imageName, + audit: session.audit, + }, + timestamp: session.timestamp, + username: session.username, + })) + // mix them in with other project audit actions: + .concat(projectAuditActions) + .sort((action1, action2) => action1.timestamp - action2.timestamp); return (