unbounded-for-shares-capped-for-lists
Installation
SKILL.md
Two bounds over the same grouping
The same GROUP BY feeds two consumers with opposite needs. A leaderboard wants the head and
nothing else; a share-of-the-whole wants the whole:
// adapted — for the list on screen
@Query("SELECT entityId, COUNT(*) AS eventCount FROM event_entity" +
" WHERE timestamp BETWEEN :start AND :end" +
" GROUP BY entityId ORDER BY eventCount DESC LIMIT 100")
suspend fun queryTopEntitiesInRange(start: LocalDateTime, end: LocalDateTime): List<EntityCount>
// adapted — for anything that divides by a total. Unbounded, and it says why.
@Query("SELECT entityId, COUNT(*) AS eventCount FROM event_entity" +
" WHERE timestamp BETWEEN :start AND :end" +
" GROUP BY entityId ORDER BY eventCount DESC")
suspend fun getEntityCountsInRange(start: LocalDateTime, end: LocalDateTime): List<EntityCount>