-
Notifications
You must be signed in to change notification settings - Fork 15
fix: correct jq argument order in world cache Nepal merge #9
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -191,13 +191,37 @@ store_random_results() { | |
| } | ||
|
|
||
| refresh_world_cache() { | ||
| local world_tmp nepal_tmp merged_tmp | ||
| world_tmp=$(mktemp "$runtime_dir/world-XXXXXX") | ||
| nepal_tmp=$(mktemp "$runtime_dir/nepal-XXXXXX") | ||
| merged_tmp=$(mktemp "$runtime_dir/merged-XXXXXX") | ||
|
|
||
| request 500 '/json/stations/search' \ | ||
| --data-urlencode 'has_geo_info=true' \ | ||
| --data-urlencode 'hidebroken=true' \ | ||
| --data-urlencode 'order=clickcount' \ | ||
| --data-urlencode 'reverse=true' \ | ||
| --data-urlencode 'limit=500' \ | ||
| | store_results "$world_cache_file" >/dev/null | ||
| > "$world_tmp" 2>/dev/null || { rm -f "$world_tmp" "$nepal_tmp" "$merged_tmp"; return 1; } | ||
|
|
||
| curl -s --max-time 12 \ | ||
| "https://all.api.radio-browser.info/json/stations/bycountrycodeexact/NP?hidebroken=true&order=clickcount&reverse=true&limit=100" \ | ||
| > "$nepal_tmp" 2>/dev/null || true | ||
|
|
||
| if [[ -s "$nepal_tmp" ]] && jq -e 'type == "array" and length > 0' "$nepal_tmp" >/dev/null 2>&1; then | ||
| jq -s ' | ||
| (.[0] // []) as $world | ||
| | (.[1] // []) as $nepal | ||
| | ($world | map(.stationuuid // "")) as $world_uuids | ||
| | ($nepal | map(select(.stationuuid as $u | ($world_uuids | index($u)) == null))) as $new | ||
| | ($new + $world)[:500] | ||
| ' "$world_tmp" "$nepal_tmp" > "$merged_tmp" | ||
|
Comment on lines
+215
to
+218
Owner
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] Preserve all priority stations before truncating Nepal stations already in |
||
| store_results "$world_cache_file" < "$merged_tmp" >/dev/null | ||
|
Owner
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] Publish the initial world data before fetching enrichment With no valid cache, |
||
| else | ||
| store_results "$world_cache_file" < "$world_tmp" >/dev/null | ||
| fi | ||
|
|
||
| rm -f "$world_tmp" "$nepal_tmp" "$merged_tmp" | ||
| } | ||
|
|
||
| refresh_world_cache_in_background() { | ||
|
|
||
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] Reuse the bounded request helper
This direct curl call skips the existing 4 MiB response limit, record-count validation, retries, and server fallback.
limit=100is a server query parameter, not a client-side bound; I confirmed an oversized Nepal response is accepted. Route the request throughrequest 100with the existing query-argument convention, and preserve the world-only fallback when the optional request fails.