···88 getPausedDuration,
99 getRemainingTime,
1010} from "../../../libs/time-periods";
1111+import { prettyPrintTime } from "../../../libs/time";
11121213// Check for paused sessions that have exceeded the max pause duration
1314export async function expirePausedSessions() {
···5253 }
5354 }
54555656+ // Calculate elapsed time
5757+ const elapsedTime = calculateElapsedTime(JSON.parse(take.periods));
5858+5559 // Auto-expire paused sessions that exceed the max pause duration
5660 if (pausedDuration > TakesConfig.MAX_PAUSE_DURATION) {
5761 let ts: string | undefined;
···6064 const res = await slackApp.client.chat.postMessage({
6165 channel: take.userId,
6266 text: `⏰ Your paused takes session has been automatically completed because it was paused for more than ${TakesConfig.MAX_PAUSE_DURATION} minutes.\n\nPlease upload your takes video in this thread within the next 24 hours!`,
6767+ blocks: [
6868+ {
6969+ type: "section",
7070+ text: {
7171+ type: "mrkdwn",
7272+ text: `⏰ Your paused takes session has been automatically completed because it was paused for more than ${TakesConfig.MAX_PAUSE_DURATION} minutes.\n\nPlease upload your takes video in this thread within the next 24 hours!`,
7373+ },
7474+ },
7575+ {
7676+ type: "divider",
7777+ },
7878+ {
7979+ type: "context",
8080+ elements: [
8181+ {
8282+ type: "mrkdwn",
8383+ text: `\`${prettyPrintTime(elapsedTime)}\`${take.description ? ` working on: *${take.description}*` : ""}`,
8484+ },
8585+ ],
8686+ },
8787+ ],
6388 });
6489 ts = res.ts;
6590 } catch (error) {
···6893 error,
6994 );
7095 }
7171-7272- // Calculate elapsed time
7373- const elapsedTime = calculateElapsedTime(JSON.parse(take.periods));
74967597 await db
7698 .update(takesTable)
···123145 }
124146 }
125147148148+ const elapsedTime = calculateElapsedTime(JSON.parse(take.periods));
149149+126150 if (endTime.remaining <= 0) {
127151 let ts: string | undefined;
128152 try {
129153 const res = await slackApp.client.chat.postMessage({
130154 channel: take.userId,
131155 text: "⏰ Your takes session has automatically completed because the time is up. Please upload your takes video in this thread within the next 24 hours!",
156156+ blocks: [
157157+ {
158158+ type: "section",
159159+ text: {
160160+ type: "mrkdwn",
161161+ text: "⏰ Your takes session has automatically completed because the time is up. Please upload your takes video in this thread within the next 24 hours!",
162162+ },
163163+ },
164164+ {
165165+ type: "divider",
166166+ },
167167+ {
168168+ type: "context",
169169+ elements: [
170170+ {
171171+ type: "mrkdwn",
172172+ text: `\`${prettyPrintTime(elapsedTime)}\`${take.description ? ` working on: *${take.description}*` : ""}`,
173173+ },
174174+ ],
175175+ },
176176+ ],
132177 });
133178134179 ts = res.ts;
···139184 );
140185 }
141186142142- const elapsedTime = calculateElapsedTime(JSON.parse(take.periods));
143143-144187 await db
145188 .update(takesTable)
146189 .set({
147190 status: "waitingUpload",
148191 completedAt: now,
149149- elapsedTimeMs: take.targetDurationMs,
192192+ elapsedTimeMs: elapsedTime,
150193 ts,
151194 notes: take.notes
152195 ? `${take.notes} (Automatically completed - time expired)`
+7-10
src/features/takes/services/upload.ts
···7676 name: "fire",
7777 });
78787979- const takeDuration = calculateElapsedTime(JSON.parse(take.periods));
8080-8179 await slackClient.chat.postMessage({
8280 channel: payload.channel,
8381 thread_ts: payload.thread_ts,
···9896 elements: [
9997 {
10098 type: "mrkdwn",
101101- text: `take by <@${user}> for \`${prettyPrintTime(takeDuration)}\` working on: *${take.description}*`,
9999+ text: `take by <@${user}> for \`${prettyPrintTime(take.elapsedTimeMs)}\` working on: *${take.description}*`,
102100 },
103101 ],
104102 },
···113111 type: "section",
114112 text: {
115113 type: "mrkdwn",
116116- text: `:video_camera: new take uploaded by <@${user}> for \`${prettyPrintTime(takeDuration)}\` working on: *${take.description}*`,
114114+ text: `:video_camera: new take uploaded by <@${user}> for \`${prettyPrintTime(take.elapsedTimeMs)}\` working on: *${take.description}*`,
117115 },
118116 },
119117 {
···218216 elements: [
219217 {
220218 type: "mrkdwn",
221221- text: `take by <@${user}> for \`${prettyPrintTime(takeDuration)}\` working on: *${take.description}*`,
219219+ text: `take by <@${user}> for \`${prettyPrintTime(take.elapsedTimeMs)}\` working on: *${take.description}*`,
222220 },
223221 ],
224222 },
···244242 if (take.length === 0) {
245243 return;
246244 }
245245+ const takeToApprove = take[0];
246246+ if (!takeToApprove) return;
247247+247248 await db
248249 .update(takesTable)
249250 .set({
···252253 })
253254 .where(eq(takesTable.id, takeId));
254255255255- const takeDuration = calculateElapsedTime(
256256- JSON.parse(take[0]?.periods as string),
257257- );
258258-259256 await slackClient.chat.postMessage({
260257 channel: payload.user.id,
261258 thread_ts: take[0]?.ts as string,
262262- text: `take approved with multiplier \`${multiplier}\` so you have earned *${Number((takeDuration * Number(multiplier)) / 60).toFixed(1)} takes*!`,
259259+ text: `take approved with multiplier \`${multiplier}\` so you have earned *${Number((takeToApprove.elapsedTimeMs * Number(multiplier)) / 60).toFixed(1)} takes*!`,
263260 });
264261265262 // delete the message from the review channel