Skip to content

Commit

Permalink
try gurantee image
Browse files Browse the repository at this point in the history
  • Loading branch information
Zainrax committed Feb 18, 2025
1 parent 18a1ab2 commit 041adcf
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions api/api/V1/Device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -947,15 +947,19 @@ export default function (app: Application, baseUrl: string) {
(request.query["at-time"] as unknown as Date)) ||
new Date();
const device = response.locals.device as Device;

const deviceHistoryEntry = await this.findOne({
where: {
DeviceId: device.id,
GroupId: device.GroupId,
fromDateTime: { [Op.lte]: atTime },
},
order: [["fromDateTime", "ASC"]],
});
const kind = (request.query.type as string) || "pov";
const query =
kind === "pov"
? "settings.referenceImagePOV"
: "settings.referenceImageInSitu";
const deviceHistoryEntry = await models.DeviceHistory.latest(
device.id,
device.GroupId,
atTime,
{
[query]: { [Op.ne]: null },
}
);
if (!deviceHistoryEntry) {
return next(
new UnprocessableError(
Expand Down Expand Up @@ -1131,7 +1135,6 @@ export default function (app: Application, baseUrl: string) {
} else if (
[DeviceType.Hybrid, DeviceType.Thermal].includes(device.kind)
) {
const kind = (request.query.type as string) || "pov";
let referenceImage;
let referenceImageFileSize;

Expand Down

0 comments on commit 041adcf

Please sign in to comment.