Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/routes/api/devices/[devEui]/pdf/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ export const GET: RequestHandler = async ({ params, url, locals: { supabase } })
const userEnd = DateTime.fromJSDate(endDate).setZone(timezoneParam).endOf('day');
const startLabel = userStart.toFormat('yyyy-MM-dd HH:mm');
const endLabel = userEnd.toFormat('yyyy-MM-dd HH:mm');
startDate = userStart.toUTC().toJSDate();
endDate = userEnd.toUTC().toJSDate();
const startDateUtc = userStart.toUTC().toJSDate();
const endDateUtc = userEnd.toUTC().toJSDate();
const startDateLocal = userStart.toJSDate();
const endDateLocal = userEnd.toJSDate();

const selectedKeys = dataKeysParam
.split(',')
Expand Down Expand Up @@ -181,16 +183,21 @@ export const GET: RequestHandler = async ({ params, url, locals: { supabase } })
const deviceDataResponse = isReport
? await deviceDataService.getDeviceDataForReport({
devEui,
startDate,
endDate,
startDate: startDateUtc,
endDate: endDateUtc,
timezone: timezoneParam,
columns: requestedAlertPoints.map((p) => p.data_point_key as string),
ops: requestedAlertPoints.map((p) => p.operator as string),
mins: requestedAlertPoints.map((p) => (p.min ?? p.value) as number),
maxs: requestedAlertPoints.map((p) => p.max ?? null),
intervalMinutes: 30
})
: await deviceDataService.getDeviceDataByDateRange(devEui, startDate, endDate, timezoneParam);
: await deviceDataService.getDeviceDataByDateRange(
devEui,
startDateLocal,
endDateLocal,
timezoneParam
);

let deviceData: DeviceDataRecord[] = [];
let alertPoints: ReportAlertPoint[] = requestedAlertPoints;
Expand Down
Loading