From 3456e693662320559854f482803bddbc52672510 Mon Sep 17 00:00:00 2001 From: ccbikai Date: Sun, 11 May 2025 21:53:23 +0800 Subject: [PATCH] feat: enhance realtime globe functionality - Reintroduced the realtime dashboard tab in the navigation menu. - Updated Globe component to utilize geographic coordinates for live session locations. - Added dynamic resizing for the globe based on viewport width. - Implemented stop rotation feature on mouse down for better user interaction. - Cleaned up commented code and improved type definitions in event logging. --- app/components/dashboard/Nav.vue | 4 +- app/components/dashboard/realtime/Globe.vue | 102 ++++++++++++++------ app/components/dashboard/realtime/Index.vue | 1 + server/api/logs/events.ts | 3 +- server/api/logs/locations.ts | 22 +++++ 5 files changed, 98 insertions(+), 34 deletions(-) create mode 100644 server/api/logs/locations.ts diff --git a/app/components/dashboard/Nav.vue b/app/components/dashboard/Nav.vue index 87871a0..1f74333 100644 --- a/app/components/dashboard/Nav.vue +++ b/app/components/dashboard/Nav.vue @@ -18,9 +18,9 @@ const route = useRoute() {{ $t('nav.analysis') }} - + diff --git a/app/components/dashboard/realtime/Globe.vue b/app/components/dashboard/realtime/Globe.vue index 2493eae..b07f527 100644 --- a/app/components/dashboard/realtime/Globe.vue +++ b/app/components/dashboard/realtime/Globe.vue @@ -1,49 +1,74 @@ diff --git a/app/components/dashboard/realtime/Index.vue b/app/components/dashboard/realtime/Index.vue index 7175ef0..cb59ed4 100644 --- a/app/components/dashboard/realtime/Index.vue +++ b/app/components/dashboard/realtime/Index.vue @@ -7,5 +7,6 @@ + diff --git a/server/api/logs/events.ts b/server/api/logs/events.ts index f0fa6ec..98b266e 100644 --- a/server/api/logs/events.ts +++ b/server/api/logs/events.ts @@ -17,7 +17,7 @@ interface WAEEvents { function events2logs(events: WAEEvents[]) { return events.map((event) => { - const blobs = Array.from({ length: Object.keys(blobsMap).length }).fill(0).reduce((_, _c, i) => { + const blobs = Array.from({ length: Object.keys(blobsMap).length }).fill(0).reduce((_, _c, i) => { _.push(event[`blob${i + 1}`]) return _ }, []) @@ -25,7 +25,6 @@ function events2logs(events: WAEEvents[]) { ...blobs2logs(blobs), id: event.index1, timestamp: event.timestamp, - _sample_interval: event._sample_interval, } }) } diff --git a/server/api/logs/locations.ts b/server/api/logs/locations.ts new file mode 100644 index 0000000..b868fd8 --- /dev/null +++ b/server/api/logs/locations.ts @@ -0,0 +1,22 @@ +import type { H3Event } from 'h3' +import { QuerySchema } from '@@/schemas/query' + +const { select, and, notEq } = SqlBricks + +function query2sql(query: Query, event: H3Event): string { + const filter = query2filter(query) + const { dataset } = useRuntimeConfig(event) + const sql = select(`blob8 as ${blobsMap.blob8},double1 as ${doublesMap.double1},double2 as ${doublesMap.double2},count() as count`) + .from(dataset) + .where(and([notEq('double1', 0), notEq('double2', 0), filter])) + .groupBy([blobsMap.blob8, doublesMap.double1, doublesMap.double2]) + appendTimeFilter(sql, query) + return sql.toString() +} + +export default eventHandler(async (event) => { + const query = await getValidatedQuery(event, QuerySchema.parse) + const sql = query2sql(query, event) + + return useWAE(event, sql) +})