(now: Date)
| 38 | } |
| 39 | |
| 40 | function liveSessionWhere(now: Date) { |
| 41 | return and( |
| 42 | eq(schema.freeSession.status, 'active'), |
| 43 | gt(schema.freeSession.expires_at, now), |
| 44 | sql`NOT EXISTS ( |
| 45 | SELECT 1 FROM ${schema.user} |
| 46 | WHERE ${schema.user.id} = ${schema.freeSession.user_id} |
| 47 | AND ${schema.user.banned} = true |
| 48 | )`, |
| 49 | ) |
| 50 | } |
| 51 | |
| 52 | function sortCounts<T extends { count: number }>(rows: T[]): T[] { |
| 53 | return [...rows].sort((a, b) => b.count - a.count) |
no outgoing calls
no test coverage detected