Commit c8fce31
Fix OOM in search-sync + schedule daily cron (#313)
* schedule sync-device-definitions-search daily, remove deprecated r1 CLI
Replaces the r1-search-gsheet-sync cron entry with device-definitions-search-sync
(daily 13:00 UTC) and drops the sync-r1-compatibilty subcommand and its
registration. The runtime read path for r1_compatibility is untouched.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix pagination in tableland definitions query to stop OOM
QueryDefinitionsCustom built its SQL with OFFSET set to the raw pageIndex
instead of pageIndex*500, so each page overlapped the previous by 499 rows.
The caller in sync-device-definitions-search also broke only when a page
returned fewer than 50 rows (vs. the 500-row page size), so for any
manufacturer with more than 50 definitions the loop kept advancing by one
row while appending a near-duplicate page each iteration. The resulting
documents slice grew by roughly N*(N-50)/2 per make and drove the job OOM.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor sync-device-definitions-search for per-make flush and testability
Splits Execute() into a SearchIndexer interface (with a typesense-backed
implementation) and two pure orchestration functions: buildManufacturerDocuments
converts a single manufacturer's tableland definitions into search entries, and
runSearchSync walks manufacturers and upserts one make at a time. The
per-make flush bounds steady-state memory to one make's documents instead of
retaining the entire catalog until the end, and switches uploads from
per-document Upsert calls to the batched Documents().Import upsert action.
Adds unit tests covering the year filter, field population, pagination
termination, error propagation, and per-make flush behaviour. Tests use the
existing gomock mocks for IdentityAPI and DeviceDefinitionOnChainService plus
a generated MockSearchIndexer; no database is required.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 69412db commit c8fce31
8 files changed
Lines changed: 438 additions & 366 deletions
File tree
- charts/device-definitions-api
- cmd/device-definitions-api
- internal/infrastructure/gateways
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | 58 | | |
60 | 59 | | |
61 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments