-
-
Notifications
You must be signed in to change notification settings - Fork 129
feat(api): add updated_at filter and sort to GET /device #2719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
933a94f
e0c9225
705dc2f
acac0f8
075570d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -959,12 +959,23 @@ | |
| return `(updated_at ${comparison} toDateTime('${safeCursorTime}') OR (updated_at = toDateTime('${safeCursorTime}') AND device_id > '${safeCursorDeviceId}'))` | ||
| } | ||
|
|
||
| function buildReadDevicesCFUpdatedAtGtCondition(updatedAtGt: string | undefined) { | ||
| if (!updatedAtGt) | ||
| return '' | ||
|
|
||
| const safeUpdatedAtGt = escapeSqlString(formatDateCF(updatedAtGt)) | ||
| return `updated_at > toDateTime('${safeUpdatedAtGt}')` | ||
| } | ||
|
|
||
| function buildReadDevicesCFOuterConditions(params: ReadDevicesParams, devicesOrder: DevicesOrderCF | null) { | ||
| const conditions = [buildReadDevicesCFCursorCondition(params.cursor, devicesOrder)] | ||
| const conditions = [ | ||
| buildReadDevicesCFCursorCondition(params.cursor, devicesOrder), | ||
| buildReadDevicesCFUpdatedAtGtCondition(params.updated_at_gt), | ||
|
riderx marked this conversation as resolved.
|
||
| ] | ||
| return conditions.filter(Boolean) | ||
| } | ||
|
|
||
| export function buildReadDevicesCFQuery(params: ReadDevicesParams, customIdMode: boolean) { | ||
|
Check failure on line 978 in supabase/functions/_backend/utils/cloudflare.ts
|
||
| const limit = normalizeAnalyticsLimit(params.limit) | ||
| const conditions: string[] = [`index1 = '${escapeSqlString(params.app_id)}'`] | ||
|
|
||
|
|
@@ -996,6 +1007,11 @@ | |
| conditions.push(`blob2 = '${escapeSqlString(params.version_name)}'`) | ||
| } | ||
|
|
||
| if (params.updated_at_gt) { | ||
| const safeUpdatedAtGt = escapeSqlString(formatDateCF(params.updated_at_gt)) | ||
| conditions.push(`timestamp > toDateTime('${safeUpdatedAtGt}')`) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Filtered reads that include country data can now return Prompt for AI agents |
||
| } | ||
|
|
||
| const devicesOrder = getReadDevicesCFOrder(params) | ||
| const outerConditions = buildReadDevicesCFOuterConditions(params, devicesOrder) | ||
| const includeCountryCode = !!params.deviceIds?.length | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: High-precision cutoffs lose fractional digits beyond milliseconds, so
updated_at_gtcan return devices at or before the requested timestamp. Preserving the validatednormalizedtimestamp for the backend comparison would retain the advertised strict greater-than semantics.Prompt for AI agents