Skip to content

Commit

Permalink
Feature/integrate available reviews (#221)
Browse files Browse the repository at this point in the history
* Adjust getAssignments

* Remove print statements

* Adjusting assignment status color and reviewer message

* Use request_review_assignment parameter

* Remove print statements
  • Loading branch information
davidborland authored Dec 9, 2022
1 parent 03e1e4c commit a7e947e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export const RefineSelection = ({ assignments, training = false }) => {
<Assignments
type='refine'
header={ 'Under review' }
assignments={ assignments.filter(({ status, reviewer }) => status !== 'active' && reviewer?.login) }
assignments={ assignments.filter(({ status }) => status === 'review') }
/>
<Assignments
type='refine'
header={ 'Awaiting review' }
assignments={ assignments.filter(({ status, reviewer }) => status === 'waiting' && !reviewer?.login) }
assignments={ assignments.filter(({ status }) => status === 'waiting') }
/>
</Column>
<Column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const ReviewSelection = ({ review, waiting, volumes, training }) => {
<Row>
<Column>
<Header as='h4'>
Your active { training && 'training' } reviews
Your { training && 'training' } reviews
<Subheader>
{ reviewSubheader }
</Subheader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Assignment = ({ assignment, enabled }) => {
const onLoadClick = async () => {
if (assignment.status === 'waiting') {
try {
await api.requestAssignment(user._id, assignment.subvolumeId, assignment.id);
await api.requestAssignment(user._id, assignment.subvolumeId, assignment.id, true);

const newAssignment = {
...assignment,
Expand Down Expand Up @@ -72,7 +72,7 @@ export const Assignment = ({ assignment, enabled }) => {
<Label
basic
circular
content='Reviewer'
content={ assignment.status === 'review' ? 'Reviewer' : 'Latest reviewer' }
detail={ reviewer.login }
/>
</div>
Expand Down
22 changes: 14 additions & 8 deletions client/src/utils/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ export const api = {
return assignments;
}, {})).filter(({ status }) =>
getAll ? true :
reviewer ? status === 'active' || status === 'under review' :
status === 'awaiting review' || status === 'active' || status === 'under review'
);

Expand Down Expand Up @@ -287,13 +288,17 @@ export const api = {
const reviewResponse = await axios.get(`/item/${ id }/available_items_for_review`);

for (const review of reviewResponse.data) {
// Check we don't already have it
if (!assignments.find(({ id }) => id === review.id)) {
availableReviews[n - 1].assignments.push({
id: review.id,
needToLoad: true
});
const index = assignments.findIndex(({ id }) => id === review.id);

if (index !== -1) {
console.warn(`Assignment ${ review.id } in reviewer assignments and available for review`);
assignments.splice(index, 1);
}

availableReviews[n - 1].assignments.push({
id: review.id,
needToLoad: true
});
}
}
}
Expand Down Expand Up @@ -347,13 +352,14 @@ export const api = {

return comments;
},
requestAssignment: async (userId, subvolumeId, itemId) => {
requestAssignment: async (userId, subvolumeId, itemId, review = false) => {
await axios.post(`/user/${ userId }/request_assignment`,
null,
{
params: {
subvolume_id: subvolumeId,
assign_item_id: itemId
assign_item_id: itemId,
request_review_assignment: review
}
}
);
Expand Down
3 changes: 3 additions & 0 deletions client/src/utils/assignment-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ export const statusDisplay = (status) => statusValues[status];
export const statusOrder = (status) => statusValuesOrder[status];

export const statusColor = (status, reviewer) =>
statusColors[status]
/*
// Need to check reviewer login because review status is not always set...
status === 'active' || status === 'review' || status === 'completed' ? statusColors[status] :
reviewer?.login ? statusColors['review'] :
status === 'waiting' ? statusColors['waiting'] :
null;
*/

export const isActive = ({ status }) => status === 'active';

Expand Down

0 comments on commit a7e947e

Please sign in to comment.