Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Display project audit (WIP) #783

Draft
wants to merge 2 commits into
base: staging
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion src/wrappers/AuditWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -142,9 +143,43 @@ 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
.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()
// 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 (
<UserInterface
sessions={sessions}
actions={actions}
setProductsNavbarImageData={setImageData}
showAppBar={false}
/>
Expand Down