-
Notifications
You must be signed in to change notification settings - Fork 12
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
Fix missing data from CSV download #899
Conversation
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.
✅ This pull request was sent to the PullRequest network.
Check the status or cancel PullRequest code review here.
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.
PullRequest Breakdown
Reviewable lines of change
+ 319
- 206
63% TypeScript
33% TSX
3% TypeScript (tests)
1% JSON (tests)
1% JSON
Generated lines of change
+ 15
- 5
Type of change
Fix - These changes are likely to be fixing a bug or issue.
Build succeeded and deployed at https://aqualink-app-899.surge.sh |
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.
This is directionally correct, but I have a few concerns left inline for your consideration, some I am aware were issues before, but in touched code or very close to touched code, so I have brought them up to be on the safe side. Other than those issues, a little more test coverage would be great to see.
Reviewed with ❤️ by PullRequest
packages/website/src/common/Chart/MultipleSensorsCharts/DownloadCSVButton.tsx
Outdated
Show resolved
Hide resolved
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.
This is looking much better. We still have an issue with unbounded work due to no checks on the to and from date, and I've noted a few more things inline for your consideration. Bounded work is important to make sure that the database is not overloaded and that the response size is small enough to not cause issues.
There's a great talk https://www.youtube.com/watch?v=Fup5vHEvU50 that covers things like bounded work, which matters for availability, which is one of the three tiers for good security: confidentiality, integrity, availability - the so called CIA triad.
Reviewed with ❤️ by PullRequest
@@ -171,6 +175,53 @@ export class TimeSeriesController { | |||
const file = this.timeSeriesService.getSampleUploadFiles( | |||
surveyPointDataRangeDto, | |||
); | |||
res.set({ | |||
'Content-Disposition': `attachment; filename=${encodeURIComponent( | |||
`${surveyPointDataRangeDto.source}_example.csv`, |
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.
This encoding is wrapping the wrong thing. The while filename needs to be in there, not just the variable part, as per the code snippet from the previous review.
const filename = `${surveyPointDataRangeDto.source}_example.csv`;
res.set({
'Content-Disposition': `attachment; filename=${encodeURIComponent(filename)}`,
});
🔸 Bug (Important)
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.
it is the same:
res.set({
'Content-Disposition': `attachment; filename=${encodeURIComponent(
`${surveyPointDataRangeDto.source}_example.csv`,
)}`,
});
encodeURIComponent
wraps
`${surveyPointDataRangeDto.source}_example.csv`
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.
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.
Yes, the code does not assume that _example.csv
doesn't change. It is wrapped by the encodeURIComponent
call. What i meant is the same was that i don't declare
const filename = `${surveyPointDataRangeDto.source}_example.csv`;
but i just call encodeURIComponent
with ${surveyPointDataRangeDto.source}_example.csv
as argument
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.
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.
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.
resolves #879
Basically moves CSV creation to the backend, fixing the issue of missing date when selecting
all dates
.The issue was caused because the backend limits time-series data to 3 months if no other limit is specified.