fix the gosh dang automatic status update hopefully forreal this time!
This commit is contained in:
@@ -4,7 +4,6 @@ import {
|
||||
type MutationCtx,
|
||||
type QueryCtx,
|
||||
action,
|
||||
internalMutation,
|
||||
mutation,
|
||||
query,
|
||||
} from './_generated/server';
|
||||
@@ -345,15 +344,12 @@ export const endOfShiftUpdate = action({
|
||||
timeZone: 'America/Chicago',
|
||||
}),
|
||||
);
|
||||
const day = now.getDay();
|
||||
const hour = now.getHours();
|
||||
const minute = now.getMinutes();
|
||||
const day = now.getDay(), hour = now.getHours(), minute = now.getMinutes();
|
||||
if (day == 0 || day === 6) return;
|
||||
if (hour === 5) {
|
||||
await ctx.runMutation(api.statuses.updateAllStatuses, {
|
||||
message: 'End of shift',
|
||||
});
|
||||
} else if (hour === 4) {
|
||||
const message = (day === 5) ? 'Enjoying the weekend' : 'End of shift';
|
||||
if (hour === 17) {
|
||||
await ctx.runMutation(api.statuses.updateAllStatuses, { message });
|
||||
} else if (hour === 16) {
|
||||
const ms = ((60 - minute) % 60) * 60 * 1000;
|
||||
await ctx.scheduler.runAfter(ms, api.statuses.endOfShiftUpdate);
|
||||
} else return;
|
||||
|
||||
Reference in New Issue
Block a user