fix(ingest): keep a football session on its own game (#259)
ci / rust (push) Successful in 5m59s
ci / typescript (push) Successful in 9m48s

fix(ingest): keep a football session on its own game (#259)
This commit was merged in pull request #259.
This commit is contained in:
spark committed 2026-11-08 14:12:17 +00:00
1 parent d5ee4dbd5a
commit fff887121f
4 files changed
+5 -19

No files matched your search

+1 -3
View File
@@ -400,12 +400,10 @@ export class IngestService {
if (!requested) return undefined;
const event = await this.deps.db.event.findFirst({
where: { id: requested, organizationId },
select: { ingestFrom: true, ingestUntil: true, archivedAt: true },
select: { ingestFrom: true, ingestUntil: true },
});
if (!event) return undefined;
if (at < event.ingestFrom || at > event.ingestUntil) return undefined;
// Put away, and another open event covers this time (the windows overlap): the pin must not keep the next match.
if (event.archivedAt && (await this.routeToEvent(organizationId, userId, at))) return undefined;
if (!(await this.sameSession(requested, userId, at))) return undefined;
return requested;
}
-8
View File
@@ -18,14 +18,6 @@ export async function joinedEvent(db: Db, eventId: string, ids: string[]): Promi
}
if ((event.autopilot as { enabled?: boolean } | null)?.enabled === true) {
await db.photo.updateMany({ where: { id: { in: ids }, status: "READY", source: { not: "CLOUD" }, autopilotStatus: "NONE" }, data: { autopilotStatus: "PENDING" } });
// Already read on the event they left: decide them again here, without running the crop a second time.
await db.$executeRaw`
UPDATE photos
SET autopilot = (autopilot::jsonb - 'curated' - 'chosen' - 'gallery')
WHERE id = ANY(${ids}::uuid[])
AND autopilot_status = 'DONE'
AND jsonb_typeof(autopilot::jsonb) = 'object'
`;
}
for (const id of ids) await applyRename(db, id);
}
+2 -4
View File
@@ -105,10 +105,8 @@ export function eventForArrival(pinnedId: string | null, events: RoutedEvent[],
if (!pinnedId) return routeLocally(events, at);
const pinned = events.find((e) => e.id === pinnedId);
if (!pinned) {
// Not in the open list: archived or deleted. Another open event that covers this time gets the photo.
// An empty list has not loaded yet — keep the pin so a live card is not dropped in the inbox.
const routed = events.length ? routeLocally(events, at) : null;
return routed ?? pinnedId;
// Agenda cache miss: keep the open pin so USB/FTP does not dump live shots into Sem evento.
return pinnedId;
}
if (pinned.archivedAt) return routeLocally(events, at);
const t = Date.parse(at);
+2 -4
View File
@@ -126,10 +126,8 @@ describe("photos arriving on this computer", () => {
// No capture time: keep the pin (USB already filtered by the card clock; server keeps the named folder too).
expect(eventForArrival("braga", events, null)).toBe("braga");
expect(eventForArrival(null, events, null)).toBeNull();
// A pin that is not in the open list was archived. An empty list has not loaded: keep the pin.
expect(eventForArrival("missing", events, "2026-10-10T15:30:00Z")).toBe("other");
expect(eventForArrival("missing", [], "2026-10-10T15:30:00Z")).toBe("missing");
expect(eventForArrival("missing", events, "2026-09-03T15:00:00Z")).toBe("missing");
// Cache miss for the pin id: keep it (do not dump into Sem evento); archived pins fall through to the clock.
expect(eventForArrival("missing", events, "2026-10-10T15:30:00Z")).toBe("missing");
expect(eventForArrival("braga", [{ ...events[0]!, archivedAt: "2026-10-10T00:00:00Z" }, events[1]!], "2026-10-10T15:30:00Z")).toBe("other");
});