Skip to content

Commit

Permalink
Use luxon for dates as it makes timezone stuff easier
Browse files Browse the repository at this point in the history
  • Loading branch information
Lan2u committed Sep 17, 2024
1 parent b666989 commit 84c4937
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import {sheets_v4} from '@googleapis/sheets';
import {Equipment} from './return-types';
import {QzEvent} from '../../types/qz-event';
import {extractGoogleSheetData} from '../../training-sheets/google';
import {DateTime} from 'luxon';

const GOOGLE_UPDATE_INTERVAL_MS = 5 * 60 * 1000;

export type PullSheetData = (
logger: Logger,
trainingSheetId: string,
rowsSince: O.Option<Date>
rowsSince: O.Option<DateTime>
) => TE.TaskEither<Failure, sheets_v4.Schema$Spreadsheet>;

const pullNewEquipmentQuizResults = (
Expand Down Expand Up @@ -81,6 +82,7 @@ export const asyncApplyExternalEventSources = (
equipment
)()
);
equipment.lastQuizSync = O.some(DateTime.utc());
}
}
logger.info('Finished applying external event sources');
Expand Down
5 changes: 3 additions & 2 deletions src/read-models/shared-state/return-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as O from 'fp-ts/Option';
import {EmailAddress, GravatarHash} from '../../types';
import {DateTime} from 'luxon';

type OrphanedPassedQuiz = {
id: string;
Expand Down Expand Up @@ -42,9 +43,9 @@ export type Equipment = {

// Uses the actual spreadsheet timestamp rather than our local timestamp which could be
// different due to clock drift or eventual consistency issues on the google side.
lastQuizResult: O.Option<Date>;
lastQuizResult: O.Option<DateTime>;
// Uses local timestamp.
lastQuizSync: O.Option<Date>;
lastQuizSync: O.Option<DateTime>;
};

type TrainedOn = {
Expand Down

0 comments on commit 84c4937

Please sign in to comment.