Skip to content

Commit

Permalink
fix(classifier): set started_at timestamp when annotation starts
Browse files Browse the repository at this point in the history
- add `metadata._inProgress` to classifications, and set it to true when a volunteer first updates an annotation.
- set `classification.metadata.started_at` to the current time when `metadata._inProgress` is set to true.
  • Loading branch information
eatyourgreens committed Nov 8, 2024
1 parent 99983e1 commit a0ee61f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions app/classifier/classifier.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,15 @@ class Classifier extends React.Component {
});
}

updateAnnotations(annotations) {
updateAnnotations(annotations, fromUserAction = false) {
this.setState({ annotations });
this.props.actions.classify.saveAnnotations(annotations);
if (fromUserAction && !this.props.classification?.metadata._inProgress) {
this.props.actions.classify.updateMetadata({
_inProgress: true,
started_at: new Date().toISOString()
});
}
}

updateFeedback(taskId) {
Expand Down Expand Up @@ -203,12 +209,13 @@ class Classifier extends React.Component {
actions.classify.updateMetadata({ subject_dimensions });
}

// handle annotation changes from the subject viewer eg. drawing tasks
handleAnnotationChange(classification, newAnnotation) {
const { annotations } = this.state;
const index = findLastIndex(annotations, annotation => annotation.task === newAnnotation.task);
if (index > -1) {
annotations[index] = newAnnotation;
this.updateAnnotations(annotations);
this.updateAnnotations(annotations, true);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/classifier/task.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Task extends React.Component {
const index = findLastIndex(annotations, annotation => annotation.task === newAnnotation.task);
if (index > -1) {
annotations[index] = newAnnotation;
this.props.updateAnnotations(annotations);
this.props.updateAnnotations(annotations, true);
}
}

Expand Down
1 change: 1 addition & 0 deletions app/redux/ducks/classify.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function createNewClassification(project, workflow, subject, goldStandardMode, l
// Delete the metadata key because we don't want volunteers to see it.
subject.update({ 'metadata.intervention': undefined });
const newMetadata = {
_inProgress: false,
workflow_version: workflow.version,
started_at: (new Date()).toISOString(),
user_agent: navigator.userAgent,
Expand Down

0 comments on commit a0ee61f

Please sign in to comment.