Conversation
Codecov Report
@@ Coverage Diff @@
## main #45 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 2 2
Lines 106 106
=====================================
Misses 106 106 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
| for (const paper of papers) { | ||
| const paperDate = format(paper.date, 'yyyy-MM-dd'); | ||
| if (paperDate === today) { | ||
| displayPapers.push(paper); |
There was a problem hiding this comment.
At the moment, all the categories seem to work as expected except for today's papers. When the data has papers from the day of, the displayPapers array here is still returned as empty. I'm currently looking into this, however, I've been having some issues with debugging since these functions are only run when the app is rendered in app.js. I've put up what I have at the moment in launch.json for some feedback, but perhaps I should be adding these date filtering functions in a new JS file? Not too sure, let me know your thoughts!
There was a problem hiding this comment.
See comment for src/dashboard/categories.js
|
Cross-reference #27 |
| let papers = []; | ||
| const category = data.find(cat => cat.id === id); | ||
| papers = category && category.papers.map(toDate).sort(byDate).slice(1, limit); | ||
| papers = category && category.papers.map(toDate).sort(byDate).slice(1); |
| for (const paper of papers) { | ||
| const paperDate = format(paper.date, 'yyyy-MM-dd'); | ||
| if (paperDate === today) { | ||
| displayPapers.push(paper); |
There was a problem hiding this comment.
See comment for src/dashboard/categories.js
| const today = format(now, 'yyyy-MM-dd'); | ||
| const displayPapers = []; | ||
|
|
||
| if (range === 'today') { |
There was a problem hiding this comment.
Maybe single loop and use https://date-fns.org/v2.29.3/docs/isWithinInterval
|
|
||
| if (range === 'today' && paperDate === today) { // Today's papers | ||
| displayPapers.push(paper); | ||
| } else if (range === 'days' && paperDate >= daysAgo && paperDate < today) { // Papers from 4 days ago |
There was a problem hiding this comment.
I attempted to use isWithinInterval here, but soon realized it had a lot of complications with timezones - the downloaded data would be in UTC, but it would get automatically converted to EST when comparing it to the current date which made things a bit more difficult to work with. I found that it was easier to manipulate date strings rather than Date objects for our purposes.
Filters through all recent papers from the past month and creates the following categories/headings in the UI: