Skip to content

Categorize papers by recency#45

Merged
Suhyma merged 10 commits intomainfrom
27-categorize-article-collection-by-date
Apr 11, 2023
Merged

Categorize papers by recency#45
Suhyma merged 10 commits intomainfrom
27-categorize-article-collection-by-date

Conversation

@Suhyma
Copy link
Copy Markdown
Collaborator

@Suhyma Suhyma commented Apr 4, 2023

Filters through all recent papers from the past month and creates the following categories/headings in the UI:

  • Today's papers
  • Papers from the past 3 days
  • Papers from the past week
  • Rest of the papers from this month

@Suhyma Suhyma requested review from jvwong and maxkfranz April 4, 2023 16:52
@Suhyma Suhyma linked an issue Apr 4, 2023 that may be closed by this pull request
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 4, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 531e02f
Status:⚡️  Build in progress...

View logs

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 4, 2023

Codecov Report

Merging #45 (6ad77d6) into main (41afe32) will not change coverage.
The diff coverage is n/a.

❗ Current head 6ad77d6 differs from pull request most recent head 531e02f. Consider uploading reports for the commit 531e02f to get more accurate results

@@          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);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See comment for src/dashboard/categories.js

@jvwong
Copy link
Copy Markdown
Member

jvwong commented Apr 4, 2023

Cross-reference #27

Comment thread src/dashboard/categories.js Outdated
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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is the slice set to 1?

for (const paper of papers) {
const paperDate = format(paper.date, 'yyyy-MM-dd');
if (paperDate === today) {
displayPapers.push(paper);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See comment for src/dashboard/categories.js

const today = format(now, 'yyyy-MM-dd');
const displayPapers = [];

if (range === 'today') {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread src/dashboard/category-results-screen.js
@Suhyma Suhyma requested a review from jvwong April 10, 2023 19:39

if (range === 'today' && paperDate === today) { // Today's papers
displayPapers.push(paper);
} else if (range === 'days' && paperDate >= daysAgo && paperDate < today) { // Papers from 4 days ago
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

@Suhyma Suhyma merged commit 38788dd into main Apr 11, 2023
@jvwong jvwong deleted the 27-categorize-article-collection-by-date branch April 21, 2023 13:57
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.

Categorize article collection by date

2 participants