Skip to content

Commit

Permalink
Bulk verify now returns 204 status with empty response
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislaw-zakrzewski committed Oct 14, 2024
1 parent db8db9b commit 9af8949
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 27 deletions.
4 changes: 2 additions & 2 deletions data-serving/data-service/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,8 @@ paths:
items:
type: string
responses:
'200':
$ref: '#/components/responses/200Case'
'204':
$ref: '#/components/responses/204'
'400':
$ref: '#/components/responses/400'
'403':
Expand Down
30 changes: 10 additions & 20 deletions data-serving/data-service/src/controllers/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ export class CasesController {
*/
verifyBundled = async (req: Request, res: Response): Promise<void> => {
const caseBundleIds = req.body.data.caseBundleIds.map((caseBundleId: string) => new mongoose.Types.ObjectId(caseBundleId));
const verifierEmail = req.body.curator.email;
const c = await Day0Case.find({
bundleId: {$in: caseBundleIds}
});
Expand All @@ -977,39 +978,28 @@ export class CasesController {
return;
}

const verifier = await User.findOne({
email: req.body.curator.email,
});
const verifier = await User.findOne({email: verifierEmail});

if (!verifier) {
res.status(404).send({
message: `Verifier with email ${req.body.curator.email} not found.`,
message: `Verifier with email ${verifierEmail} not found.`,
});
return;
} else {
const updateData = Date.now();
await Day0Case.updateMany({bundleId: {$in: caseBundleIds}},
{
$set:
{
'curators.verifiedBy': verifier,
'revisionMetadata.updateMetadata': {
curator: verifier.email,
note: 'Case Verification',
date: updateData,
},
'curators.verifiedBy': verifier,
'revisionMetadata.updateMetadata': {
curator: verifierEmail,
note: 'Case Verification',
date: updateData,
},
},
$inc: {'revisionMetadata.revisionNumber': 1}
});
const responseCase = await Day0Case.find({
_id: req.params.id,
}).lean();
res.json(
await Promise.all(
responseCase.map((aCase) => dtoFromCase(aCase)),
),
);
return;
res.status(204).end();
}
};

Expand Down
4 changes: 2 additions & 2 deletions verification/curator-service/api/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1049,8 +1049,8 @@ paths:
items:
type: string
responses:
'200':
$ref: '#/components/responses/200Case'
'204':
$ref: '#/components/responses/204'
'400':
$ref: '#/components/responses/400'
'403':
Expand Down
4 changes: 2 additions & 2 deletions verification/curator-service/api/src/controllers/cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class CasesController {
res.status(err.response.status).send(err.response.data);
return;
}
res.status(501).send(err);
res.status(500).send(err);
}
};

Expand Down Expand Up @@ -736,7 +736,7 @@ export default class CasesController {
},
);

res.status(response.status).json(response.data);
res.status(response.status).end();
} catch (e) {
const err = e as AxiosError;
if (err.response?.status && err.response?.data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const verifyCaseBundle = createAsyncThunk<
data: { caseBundleIds, query: parsedQuery },
});

if (response.status !== 200) throw new Error(response.data.message);
if (response.status !== 204) throw new Error(response.data.message);

return;
} catch (error) {
Expand Down

0 comments on commit 9af8949

Please sign in to comment.