(updatedAtList: number[])
| 26 | } |
| 27 | |
| 28 | function buildActivity(updatedAtList: number[]) { |
| 29 | const days: Record<string, number> = {} |
| 30 | |
| 31 | updatedAtList.forEach((updatedAt) => { |
| 32 | const dayKey = getDayKey(updatedAt) |
| 33 | days[dayKey] = (days[dayKey] ?? 0) + 1 |
| 34 | }) |
| 35 | |
| 36 | const today = new Date() |
| 37 | today.setHours(0, 0, 0, 0) |
| 38 | const todayTime = today.getTime() |
| 39 | const todayStart = todayTime |
| 40 | const sevenDaysAgo = todayTime - 6 * 24 * 60 * 60 * 1000 |
| 41 | |
| 42 | return { |
| 43 | days, |
| 44 | notesUpdatedLast7Days: updatedAtList.filter( |
| 45 | updatedAt => updatedAt >= sevenDaysAgo, |
| 46 | ).length, |
| 47 | notesUpdatedToday: updatedAtList.filter( |
| 48 | updatedAt => updatedAt >= todayStart, |
| 49 | ).length, |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | const app = new Elysia({ prefix: '/notes' }) |
| 54 |
no test coverage detected