feat: add capture time overrides and apply in queries
This commit is contained in:
@@ -68,35 +68,37 @@ export async function GET(request: Request): Promise<Response> {
|
||||
}[]
|
||||
>`
|
||||
select
|
||||
id,
|
||||
bucket,
|
||||
media_type,
|
||||
mime_type,
|
||||
active_key,
|
||||
capture_ts_utc,
|
||||
date_confidence,
|
||||
width,
|
||||
height,
|
||||
rotation,
|
||||
duration_seconds,
|
||||
thumb_small_key,
|
||||
thumb_med_key,
|
||||
poster_key,
|
||||
status,
|
||||
error_message
|
||||
from assets
|
||||
a.id,
|
||||
a.bucket,
|
||||
a.media_type,
|
||||
a.mime_type,
|
||||
a.active_key,
|
||||
coalesce(o.capture_ts_utc_override, a.capture_ts_utc) as capture_ts_utc,
|
||||
a.date_confidence,
|
||||
a.width,
|
||||
a.height,
|
||||
a.rotation,
|
||||
a.duration_seconds,
|
||||
a.thumb_small_key,
|
||||
a.thumb_med_key,
|
||||
a.poster_key,
|
||||
a.status,
|
||||
a.error_message
|
||||
from assets a
|
||||
left join asset_overrides o
|
||||
on o.asset_id = a.id
|
||||
where true
|
||||
and capture_ts_utc is not null
|
||||
and (${start}::timestamptz is null or capture_ts_utc >= ${start}::timestamptz)
|
||||
and (${end}::timestamptz is null or capture_ts_utc < ${end}::timestamptz)
|
||||
and (${query.mediaType ?? null}::media_type is null or media_type = ${query.mediaType ?? null}::media_type)
|
||||
and (${query.status ?? null}::asset_status is null or status = ${query.status ?? null}::asset_status)
|
||||
and coalesce(o.capture_ts_utc_override, a.capture_ts_utc) is not null
|
||||
and (${start}::timestamptz is null or coalesce(o.capture_ts_utc_override, a.capture_ts_utc) >= ${start}::timestamptz)
|
||||
and (${end}::timestamptz is null or coalesce(o.capture_ts_utc_override, a.capture_ts_utc) < ${end}::timestamptz)
|
||||
and (${query.mediaType ?? null}::media_type is null or a.media_type = ${query.mediaType ?? null}::media_type)
|
||||
and (${query.status ?? null}::asset_status is null or a.status = ${query.status ?? null}::asset_status)
|
||||
and (
|
||||
${cursorId}::uuid is null
|
||||
or ${cursorTs}::timestamptz is null
|
||||
or (capture_ts_utc, id) > (${cursorTs}::timestamptz, ${cursorId}::uuid)
|
||||
or (coalesce(o.capture_ts_utc_override, a.capture_ts_utc), a.id) > (${cursorTs}::timestamptz, ${cursorId}::uuid)
|
||||
)
|
||||
order by capture_ts_utc asc nulls last, id asc
|
||||
order by coalesce(o.capture_ts_utc_override, a.capture_ts_utc) asc nulls last, a.id asc
|
||||
limit ${query.limit}
|
||||
`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user