Skip to content

Commit

Permalink
change telemetry created date to be more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7d8 committed Dec 12, 2024
1 parent e6bd05f commit a4592c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api",
"version": "1.1.0",
"version": "1.1.1",
"scripts": {
"build": "rm -rf lib && esbuild `find src \\( -name '*.ts' -o -name '*.tsx' \\)` --platform='node' --sourcemap --ignore-annotations --format='cjs' --target='es2022' --outdir='lib' && esbuild src/index.ts --platform='node' --sourcemap --ignore-annotations --format='cjs' --target='es2022' --outdir='lib' --banner:js='require(\"module-alias\").addAlias(\"@\", __dirname);'",
"kit": "drizzle-kit",
Expand Down
6 changes: 4 additions & 2 deletions src/globals/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type Telemetry = {
continent: string | null
country: string | null
data: Pick<z.infer<typeof telemetrySchema>, 'blueprint' | 'panel'>
created: Date
}

const processing: Telemetry[] = []
Expand All @@ -63,7 +64,8 @@ const processing: Telemetry[] = []
ip: ip.usual(),
continent: null,
country: null,
data: object.pick(telemetry, ['blueprint', 'panel'])
data: object.pick(telemetry, ['blueprint', 'panel']),
created: new Date()
}

processing.push(data)
Expand Down Expand Up @@ -94,7 +96,7 @@ const process = async(): Promise<void> => {
.values({ id })
.onConflictDoUpdate({
target: schema.telemetryPanels.id,
set: { lastUpdate: new Date() }
set: { lastUpdate: telemetry.filter((t) => t.panelId === id).sort((a, b) => b.created.getTime() - a.created.getTime())[0].created }
})
)))

Expand Down

0 comments on commit a4592c2

Please sign in to comment.