diff --git a/utils/slack.ts b/utils/slack.ts index 4360014..2ad83d1 100644 --- a/utils/slack.ts +++ b/utils/slack.ts @@ -35,11 +35,19 @@ function generateLeaderboardTable(users: user[]): string { ); const userCell = ` ${user.user}${" ".repeat(maxUsernameLength - user.user.length)} `; - const cells = uniqueTimestamps.map((timestamp, index) => - postsByDate.has(timestamp) - ? " βœ“".padEnd(dateLengths[index] + 2) - : " ".repeat(dateLengths[index] + 2), - ); + const cells = uniqueTimestamps.map((timestamp, index) => { + const date = postsByDate.has(timestamp) + ? user.posts.find( + (p) => p.timestamp.toISOString().split("T")[0] === timestamp, + ) + : null; + + return date + ? ` βœ“ ${date.timestamp.getUTCHours()}:${user.posts[0].timestamp.getUTCMinutes()}:${user.posts[0].timestamp.getUTCSeconds()}`.padEnd( + dateLengths[index] + 2, + ) + : " ".repeat(dateLengths[index] + 2); + }); return `|${userCell}|${cells.join("|")}|`; }); @@ -92,7 +100,7 @@ export async function get10DaysLeaderboard(start: Date, end: Date) { }); // display the leaderboard in markdown format - const leaderboardFormatted = `# 10 Days in Public Leaderboard from ${start.toISOString().split("T")[0]} to ${end.toISOString().split("T")[0]}\nGood Luck and have fun!πŸš€\n\n${generateLeaderboardTable(users)}`; + const leaderboardFormatted = `# 10 Days in Public Leaderboard from ${start.toISOString().split("T")[0]} to ${end.toISOString().split("T")[0]}\n\nGood Luck and have fun!\nTime next to the checkmarks is given in h:m:s local time for that userπŸš€\n\n${generateLeaderboardTable(users)}`; return leaderboardFormatted; }