Skip to content

fix: correct jq argument order in world cache Nepal merge - #9

Open
sakarstha wants to merge 1 commit into
AksharP5:mainfrom
sakarstha:fix/nepal-stations-world-cache
Open

sakarstha wants to merge 1 commit into
AksharP5:mainfrom
sakarstha:fix/nepal-stations-world-cache

Conversation

@sakarstha

Copy link
Copy Markdown

The jq -s arguments were swapped in refresh_world_cache, causing Nepal stations to be filtered out. Only 3 of 31 Nepali radio stations appeared in the globe view. Fixed by swapping the file arguments to match the variable names in the jq filter.

The jq -s arguments were swapped ($nepal_tmp $world_tmp instead of
$world_tmp $nepal_tmp), causing Nepal stations to be filtered out as
if they were world stations. This resulted in only 3 of 31 Nepali
radio stations appearing in the globe view.

@AksharP5 AksharP5 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The merge can still drop Nepal stations, and the extra request bypasses existing response limits and delays the initial globe load. Please address the three findings below before merging.

The title and description also need updating. The base branch has no Nepal merge or swapped arguments; this diff introduces Nepal-specific prioritization. I would prefer a general fix for missing country coverage using the existing fetch paths.

Verified with isolated fixtures against this commit. The existing curl fixture rejects the new request for omitting the size limit, but the error is suppressed, so it does not exercise a successful Nepal merge. Add focused coverage for that path and its failure cases.

Comment thread radio-fetch
Comment on lines +215 to +218
| ($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"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Preserve all priority stations before truncating

Nepal stations already in $world are removed from $new, so they retain their original positions and can be cut off by [:500]. I reproduced a 500-station world list with three Nepal stations at the tail and a 31-station Nepal response: the result contains only 28 Nepal stations. If country prioritization is retained, put the complete priority list first, deduplicate by UUID while preserving order, then apply the cap. Add a regression case with overlapping stations near the cutoff.

Comment thread radio-fetch
Comment on lines +207 to +209
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

Copy link
Copy Markdown
Owner

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=100 is a server query parameter, not a client-side bound; I confirmed an oversized Nepal response is accepted. Route the request through request 100 with the existing query-argument convention, and preserve the world-only fallback when the optional request fails.

Comment thread radio-fetch
| ($nepal | map(select(.stationuuid as $u | ($world_uuids | index($u)) == null))) as $new
| ($new + $world)[:500]
' "$world_tmp" "$nepal_tmp" > "$merged_tmp"
store_results "$world_cache_file" < "$merged_tmp" >/dev/null

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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, fetch_world waits for this function before returning any stations. The Nepal request runs after the world request and can add its full 12-second timeout even when the world response succeeded. A fixture with a one-second Nepal timeout added that second to first load. Return the available world data first and load any extra country coverage through the existing background expansion flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants