Skip to content

Commit

Permalink
Update date type
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislaw-zakrzewski committed Oct 25, 2024
1 parent 1d275de commit dc06def
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions data-serving/data-service/src/controllers/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ const updatedRevisionMetadata = (
day0Case: CaseDocument,
curator: string,
note?: string,
date?: Date,
date?: Date | number,
) => {
return {
creationMetadata: day0Case.revisionMetadata.creationMetadata,
updateMetadata: {
curator: curator,
note: note,
date: date || new Date(),
date: date || Date.now(),
},
revisionNumber: day0Case.revisionMetadata.revisionNumber + 1,
};
Expand Down Expand Up @@ -757,7 +757,7 @@ export class CasesController {

try {
this.addGeoResolution(req);
const currentDate: Date = new Date();
const currentDate = Date.now();
const curator = req.body.curator.email;
const receivedCase = {
...req.body,
Expand All @@ -774,9 +774,9 @@ export class CasesController {
},
},
} as CaseDTO;
receivedCase.events.dateLastModified = currentDate;

const c = fillEmpty(new Day0Case(await caseFromDTO(receivedCase)));
c.set({'events.dateLastModified': currentDate});

let result;
if (req.query.validate_only) {
Expand Down Expand Up @@ -854,7 +854,7 @@ export class CasesController {
});
return;
} else {
const updateDate = new Date();
const updateDate = Date.now();
c.set({
curators: {
createdBy: c.curators.createdBy,
Expand Down Expand Up @@ -1096,7 +1096,7 @@ export class CasesController {
return;
}
const caseDetails = await caseFromDTO(req.body);
const updateDate = new Date();
const updateDate = Date.now();
c.set({
...caseDetails,
revisionMetadata: updatedRevisionMetadata(
Expand Down
4 changes: 3 additions & 1 deletion data-serving/data-service/src/model/events.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import mongoose from 'mongoose';
import { YesNo } from '../types/enums';
import { dateFieldInfo } from './date';
import validateEnv from '../util/validate-env';

export enum HospitalizationReason {
Monitoring = 'monitoring',
Expand All @@ -22,7 +24,7 @@ export const EventsSchema = new mongoose.Schema(
type: Date,
required: true,
},
dateLastModified: Date,
dateLastModified: { ...dateFieldInfo(validateEnv().OUTBREAK_DATE) },
dateOnset: Date,
dateConfirmation: Date,
confirmationMethod: String,
Expand Down

0 comments on commit dc06def

Please sign in to comment.