From 85fd6233b186ae9d40cb38e028e4110b1c980041 Mon Sep 17 00:00:00 2001 From: jona159 Date: Tue, 14 Jul 2026 16:03:36 +0200 Subject: [PATCH] fix: rm redundant query --- app/db/models/measurement.server.ts | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/app/db/models/measurement.server.ts b/app/db/models/measurement.server.ts index b754efef..6decc905 100644 --- a/app/db/models/measurement.server.ts +++ b/app/db/models/measurement.server.ts @@ -1,5 +1,4 @@ import { and, desc, eq, gt, gte, inArray, lt, lte, sql } from 'drizzle-orm' -import { ArchivedDeviceError } from './device.server' import { type LastMeasurement, location, @@ -225,24 +224,7 @@ export async function saveMeasurements( const deviceLocationUpdates = getLocationUpdates(measurements) await drizzleClient.transaction(async (tx) => { - const [currentDevice] = await tx - .select({ - id: device.id, - archivedAt: device.archivedAt, - }) - .from(device) - .where(eq(device.id, minimalDevice.id)) - .limit(1) - - if (!currentDevice) { - const error = new Error('Device not found') - error.name = 'NotFoundError' - throw error - } - - if (currentDevice.archivedAt) { - throw new ArchivedDeviceError(currentDevice.id) - } + timing?.mark('transactionStart') const locations = deviceLocationUpdates.length > 0