Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f97ed6da04 |
@@ -37,9 +37,15 @@ export async function getSessionsSummary() {
|
||||
}
|
||||
|
||||
export async function getSessionTimeline(playSessionId: number, bucketMs = 1000) {
|
||||
// Reuse the same expression object (not a `sql`bucket`` alias reference)
|
||||
// in groupBy/orderBy - drizzle doesn't emit a literal `AS bucket` that
|
||||
// SQLite's GROUP BY/ORDER BY could resolve a bare "bucket" identifier
|
||||
// against, so referencing it by name causes "no such column: bucket".
|
||||
const bucket = sql<number>`(${sessionEvents.tsMs} / ${bucketMs}) * ${bucketMs}`;
|
||||
|
||||
return db
|
||||
.select({
|
||||
bucket: sql<number>`(${sessionEvents.tsMs} / ${bucketMs}) * ${bucketMs}`,
|
||||
bucket,
|
||||
sessionDeviceId: sessionEvents.sessionDeviceId,
|
||||
slotLabel: sessionDevices.slotLabel,
|
||||
avgValue: sql<number>`avg(${sessionEvents.value})`,
|
||||
@@ -48,8 +54,8 @@ export async function getSessionTimeline(playSessionId: number, bucketMs = 1000)
|
||||
.from(sessionEvents)
|
||||
.innerJoin(sessionDevices, eq(sessionEvents.sessionDeviceId, sessionDevices.id))
|
||||
.where(and(eq(sessionEvents.playSessionId, playSessionId), ne(sessionEvents.commandType, "stop")))
|
||||
.groupBy(sql`bucket`, sessionEvents.sessionDeviceId)
|
||||
.orderBy(sql`bucket`);
|
||||
.groupBy(bucket, sessionEvents.sessionDeviceId)
|
||||
.orderBy(bucket);
|
||||
}
|
||||
|
||||
export async function getDeviceUsageStats() {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sexy",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
Reference in New Issue
Block a user