Repository navigation
feat(export): date range for the JSON exports - #857
Open
RaoufGhrissi wants to merge 1 commit into
Open
RaoufGhrissi wants to merge 1 commit into
RaoufGhrissi wants to merge 1 commit into
Conversation
/api/0/export and /api/0/buckets/<id>/export take optional start and end (RFC 3339), like the CSV export already did: the events overlapping the range, cut to it, as /events returns them. Without them, the export is the whole history, unchanged. Invalid dates answer 400, an empty range exports the buckets without events.
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryAdds optional RFC 3339
No actionable issues were found. Tests were reviewed but not run. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[JSON export request] --> B[Parse optional dates]
B -->|Invalid date| C[400 JSON response]
B -->|Valid dates| D[Export responder]
D --> E[Datastore worker]
E --> F[Select and clip overlapping events]
F --> G[Write JSON rows to temporary file]
G --> H[Stream download]
Reviews (1) · Last reviewed commit: "feat(export): date range for the JSON ex..." · Reviewed by Greptile |
Contributor
|
Thanks! Matching the CSV export's
I'll do a full review as soon as CI has run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The JSON exports can't be limited to a period today:
/api/0/exportand/api/0/buckets/<id>/exportalways return a bucket's whole history, while the CSV export already acceptsstart/end. This adds the same optionalstartandend(RFC 3339) to both JSON exports./eventsand the CSV export.start/end, the export is unchanged, the whole history, so existing clients keep working./events. An empty range (startafterend) exports the buckets without events.The range goes from the endpoints through
Datastore::export_to_fileto the streaming serializer inaw-datastore/src/export.rs, replacing its fixed "everything" window. The export still streams row by row.Tests
ranged_json_export_matches_get_events_for_the_same_range: the ranged export equalsget_eventsfor the same range, for one bucket and for all.json_export_with_an_empty_range_has_no_events.json_exports_take_a_date_range(API): both endpoints, an event over midnight cut to the range, one side only, no range, and bad dates answering 400.cargo test -p aw-datastore -p aw-serverpasses, and the changed lines are clippy-clean.The web UI side, an export dialog with this date range, is a separate PR in aw-webui.