fix the gosh dang automatic status update hopefully forreal this time!

This commit is contained in:
2025-09-16 22:04:36 -05:00
parent 7e7e92b89a
commit b737fa22c3
8 changed files with 62 additions and 34 deletions

View File

@@ -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;