This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

bug: fix bad time on the upload and approved messages

+58 -18
+2 -2
src/features/takes/handlers/stop.ts
··· 58 58 elements: [ 59 59 { 60 60 type: "mrkdwn", 61 - text: `*Duration:* ${prettyPrintTime(elapsed)} ${notes ? `\n*Notes:* ${notes}` : ""}`, 61 + text: `*Elapsed Time:* \`${prettyPrintTime(elapsed)}\`${pausedTakeToStop.description ? ` working on: *${pausedTakeToStop.description}*` : ""}`, 62 62 }, 63 63 ], 64 64 }, ··· 111 111 elements: [ 112 112 { 113 113 type: "mrkdwn", 114 - text: `*Duration:* ${prettyPrintTime(elapsed)} ${notes ? `\n*Notes:* ${notes}` : ""}`, 114 + text: `\`${prettyPrintTime(elapsed)}\`${activeTakeToStop.description ? ` Working on: *${activeTakeToStop.description}*` : ""}`, 115 115 }, 116 116 ], 117 117 },
+49 -6
src/features/takes/services/notifications.ts
··· 8 8 getPausedDuration, 9 9 getRemainingTime, 10 10 } from "../../../libs/time-periods"; 11 + import { prettyPrintTime } from "../../../libs/time"; 11 12 12 13 // Check for paused sessions that have exceeded the max pause duration 13 14 export async function expirePausedSessions() { ··· 52 53 } 53 54 } 54 55 56 + // Calculate elapsed time 57 + const elapsedTime = calculateElapsedTime(JSON.parse(take.periods)); 58 + 55 59 // Auto-expire paused sessions that exceed the max pause duration 56 60 if (pausedDuration > TakesConfig.MAX_PAUSE_DURATION) { 57 61 let ts: string | undefined; ··· 60 64 const res = await slackApp.client.chat.postMessage({ 61 65 channel: take.userId, 62 66 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!`, 67 + blocks: [ 68 + { 69 + type: "section", 70 + text: { 71 + type: "mrkdwn", 72 + 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!`, 73 + }, 74 + }, 75 + { 76 + type: "divider", 77 + }, 78 + { 79 + type: "context", 80 + elements: [ 81 + { 82 + type: "mrkdwn", 83 + text: `\`${prettyPrintTime(elapsedTime)}\`${take.description ? ` working on: *${take.description}*` : ""}`, 84 + }, 85 + ], 86 + }, 87 + ], 63 88 }); 64 89 ts = res.ts; 65 90 } catch (error) { ··· 68 93 error, 69 94 ); 70 95 } 71 - 72 - // Calculate elapsed time 73 - const elapsedTime = calculateElapsedTime(JSON.parse(take.periods)); 74 96 75 97 await db 76 98 .update(takesTable) ··· 123 145 } 124 146 } 125 147 148 + const elapsedTime = calculateElapsedTime(JSON.parse(take.periods)); 149 + 126 150 if (endTime.remaining <= 0) { 127 151 let ts: string | undefined; 128 152 try { 129 153 const res = await slackApp.client.chat.postMessage({ 130 154 channel: take.userId, 131 155 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!", 156 + blocks: [ 157 + { 158 + type: "section", 159 + text: { 160 + type: "mrkdwn", 161 + 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!", 162 + }, 163 + }, 164 + { 165 + type: "divider", 166 + }, 167 + { 168 + type: "context", 169 + elements: [ 170 + { 171 + type: "mrkdwn", 172 + text: `\`${prettyPrintTime(elapsedTime)}\`${take.description ? ` working on: *${take.description}*` : ""}`, 173 + }, 174 + ], 175 + }, 176 + ], 132 177 }); 133 178 134 179 ts = res.ts; ··· 139 184 ); 140 185 } 141 186 142 - const elapsedTime = calculateElapsedTime(JSON.parse(take.periods)); 143 - 144 187 await db 145 188 .update(takesTable) 146 189 .set({ 147 190 status: "waitingUpload", 148 191 completedAt: now, 149 - elapsedTimeMs: take.targetDurationMs, 192 + elapsedTimeMs: elapsedTime, 150 193 ts, 151 194 notes: take.notes 152 195 ? `${take.notes} (Automatically completed - time expired)`
+7 -10
src/features/takes/services/upload.ts
··· 76 76 name: "fire", 77 77 }); 78 78 79 - const takeDuration = calculateElapsedTime(JSON.parse(take.periods)); 80 - 81 79 await slackClient.chat.postMessage({ 82 80 channel: payload.channel, 83 81 thread_ts: payload.thread_ts, ··· 98 96 elements: [ 99 97 { 100 98 type: "mrkdwn", 101 - text: `take by <@${user}> for \`${prettyPrintTime(takeDuration)}\` working on: *${take.description}*`, 99 + text: `take by <@${user}> for \`${prettyPrintTime(take.elapsedTimeMs)}\` working on: *${take.description}*`, 102 100 }, 103 101 ], 104 102 }, ··· 113 111 type: "section", 114 112 text: { 115 113 type: "mrkdwn", 116 - text: `:video_camera: new take uploaded by <@${user}> for \`${prettyPrintTime(takeDuration)}\` working on: *${take.description}*`, 114 + text: `:video_camera: new take uploaded by <@${user}> for \`${prettyPrintTime(take.elapsedTimeMs)}\` working on: *${take.description}*`, 117 115 }, 118 116 }, 119 117 { ··· 218 216 elements: [ 219 217 { 220 218 type: "mrkdwn", 221 - text: `take by <@${user}> for \`${prettyPrintTime(takeDuration)}\` working on: *${take.description}*`, 219 + text: `take by <@${user}> for \`${prettyPrintTime(take.elapsedTimeMs)}\` working on: *${take.description}*`, 222 220 }, 223 221 ], 224 222 }, ··· 244 242 if (take.length === 0) { 245 243 return; 246 244 } 245 + const takeToApprove = take[0]; 246 + if (!takeToApprove) return; 247 + 247 248 await db 248 249 .update(takesTable) 249 250 .set({ ··· 252 253 }) 253 254 .where(eq(takesTable.id, takeId)); 254 255 255 - const takeDuration = calculateElapsedTime( 256 - JSON.parse(take[0]?.periods as string), 257 - ); 258 - 259 256 await slackClient.chat.postMessage({ 260 257 channel: payload.user.id, 261 258 thread_ts: take[0]?.ts as string, 262 - text: `take approved with multiplier \`${multiplier}\` so you have earned *${Number((takeDuration * Number(multiplier)) / 60).toFixed(1)} takes*!`, 259 + text: `take approved with multiplier \`${multiplier}\` so you have earned *${Number((takeToApprove.elapsedTimeMs * Number(multiplier)) / 60).toFixed(1)} takes*!`, 263 260 }); 264 261 265 262 // delete the message from the review channel