Skip to content

Range param step updates#1580

Open
JoshuaVulcan wants to merge 6 commits into
ERA-8348from
ERA-13007
Open

Range param step updates#1580
JoshuaVulcan wants to merge 6 commits into
ERA-8348from
ERA-13007

Conversation

@JoshuaVulcan
Copy link
Copy Markdown
Collaborator

@JoshuaVulcan JoshuaVulcan commented May 27, 2026

feat: new range param steps, as per API updates.
feat: updating/simplifing geojson overlay, unbinding map moveend events to match.

What does this PR do?

https://allenai.atlassian.net/browse/ERA-13007

Evidence

N/A

Relevant link(s)

Notes

N/A

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 27, 2026

🚀 PR Environment Deployed

App Sync Health Image
pr-web-era-13007 ✅ Synced ✅ Healthy 78dec609fe55c575e7f87245bb8fa24f8b00d2ab

Access: https://era-13007.dev.pamdas.org

View in ArgoCD

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates vector-tile range parameter handling to match API step buckets, and refactors map overlay/tiles integration to simplify source management and realtime overlay fetching behavior.

Changes:

  • Add getVtRangeParam + buildVtTileUrl utilities and update track/subject tile layers to use stepped range buckets.
  • Adjust realtime overlay fetching to paginate and remove bbox dependency; add segment eviction to prevent unbounded growth.
  • Improve Mapbox layer/source cleanup safety (safeRemoveMapLayer) and update related layer cleanup logic/tests.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/withSocketConnection/useRealTimeImplementation/config.js Clarifies ordering requirement for overlay update vs subject store overwrite.
src/utils/tracks.js Adds stepped range bucket logic and centralizes VT tile URL builder.
src/utils/tracks.test.js Adds unit tests for getVtRangeParam bucket selection.
src/utils/map.js Makes safeRemoveMapLayer resilient by checking layer existence first.
src/TrackSegmentsLayer/index.js Uses getVtRangeParam/buildVtTileUrl, memoizes visible IDs, and cleans up map source on unmount/range change.
src/TrackSegmentsLayer/index.test.js Updates expected range behavior and adds parametrized range tests (but mock needs fixing).
src/SubjectTrackLegend/index.js Removes per-item description field from legend items.
src/SubjectTileLayer/index.test.js Adds getVtRangeParam mock (but mock needs fixing).
src/SubjectTileLayer/index.js Switches to its own vector tile source and cleans up that source on unmount/range change.
src/Map/index.js Refactors overlay fetch into callback and removes map dependency from overlay refresh.
src/ducks/realtime-overlay.js Changes overlay subject fetch to paginate and adds eviction of stale segments in reducer.

Comment thread src/TrackSegmentsLayer/index.test.js Outdated
Comment on lines +23 to +29
jest.mock('../utils/tracks', () => ({
getVtRangeParam: (days) => {
const steps = [30, 45, 60, 90, 150, 210, 365, 500];
const step = steps.find((s) => days <= s);
return step !== undefined ? String(step) : 'all';
},
}));
Comment thread src/SubjectTileLayer/index.test.js Outdated
Comment on lines +39 to +45
jest.mock('../utils/tracks', () => ({
getVtRangeParam: (days) => {
const steps = [30, 45, 60, 90, 150, 210, 365, 500];
const step = steps.find((s) => days <= s);
return step !== undefined ? String(step) : 'all';
},
}));
Comment thread src/SubjectTileLayer/index.js Outdated
Comment on lines 42 to 43
// Ensure the shared vector tile source exists (TrackSegmentsLayer may
// have already created it with the same range param).
Comment thread src/ducks/realtime-overlay.js Outdated
Comment on lines +109 to +114
const subjectsData = await recursivePaginatedQuery(
axios.get(SUBJECTS_API_URL, {
cancelToken: cancelToken.token,
params: { updated_since: updatedSince, use_lkl: true, include_inactive: false },
})
) ?? [];
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Comment thread src/ducks/realtime-overlay.js Outdated
Comment on lines +229 to +233
// Evict segments outside the overlay window before appending; discard
// entries with no start_time to prevent unbounded growth from malformed payloads.
const cutoff = new Date(Date.now() - REALTIME_OVERLAY_WINDOW_MS).toISOString();
const features = [
...(state.segments.features || []).filter(
Comment thread src/utils/tracks.test.js Outdated
[500, '500'],
[501, 'all'],
[999, 'all'],
])('returns %s for %i days', (days, expected) => {
Comment thread src/TrackSegmentsLayer/index.test.js Outdated
[500, '500'],
[501, 'all'],
[999, 'all'],
])('uses range=%s in tile URL when track length is %i days', (trackLengthInDays, expectedRange) => {
Comment thread src/TrackSegmentsLayer/index.test.js Outdated
Comment on lines 377 to 396
@@ -363,7 +393,6 @@ describe('TrackSegmentsLayer', () => {

expect(safeRemoveMapLayer).toHaveBeenCalledWith(mockMap, 'track-segments-layer');
expect(safeRemoveMapLayer).toHaveBeenCalledWith(mockMap, 'track-segments-start-layer');
// Source must NOT be removed — it is shared with SubjectTileLayer
expect(safeRemoveMapLayer).toHaveBeenCalledTimes(2);
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comment thread src/ducks/realtime-overlay.js Outdated
Comment on lines +229 to +232
// Discard segments (existing or incoming) with no start_time or outside
// the overlay window to prevent unbounded growth from malformed payloads.
const cutoff = new Date(Date.now() - REALTIME_OVERLAY_WINDOW_MS).toISOString();
const isWithinWindow = (f) => f.properties?.start_time && f.properties.start_time >= cutoff;
Comment thread src/TrackSegmentsLayer/index.test.js Outdated
Comment on lines +24 to +31
jest.mock('../utils/tracks', () => ({
getVtRangeParam: (days) => {
const steps = [30, 45, 60, 90, 150, 210, 365, 500];
const step = steps.find((s) => days <= s);
return step !== undefined ? String(step) : 'all';
},
buildVtTileUrl: (rangeParam) => `http://test-api.com/observations/segments/tiles/{z}/{x}/{y}.pbf?range=${rangeParam}`,
}));
Comment thread src/SubjectTileLayer/index.test.js Outdated
Comment on lines +39 to +46
jest.mock('../utils/tracks', () => ({
getVtRangeParam: (days) => {
const steps = [30, 45, 60, 90, 150, 210, 365, 500];
const step = steps.find((s) => days <= s);
return step !== undefined ? String(step) : 'all';
},
buildVtTileUrl: (rangeParam) => `http://test-api.com/observations/segments/tiles/{z}/{x}/{y}.pbf?range=${rangeParam}`,
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants