Skip to content
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 #757: reject posts without publication date #823

Merged
merged 3 commits into from
Mar 10, 2020

Conversation

Silvyre
Copy link
Contributor

@Silvyre Silvyre commented Mar 9, 2020

Issue This PR Addresses

Fixes #757

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

  • Posts missing a publication date will no longer be processed/displayed (with tests updated accordingly).
  • If a post is missing a date of last update but has a publication date, its date of last update will be set to its publication date.
  • (As a result, this PR rids Telescope of an infamous nuisance post...)

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

cindyorangis
cindyorangis previously approved these changes Mar 9, 2020
Copy link
Contributor

@cindyorangis cindyorangis left a comment

Choose a reason for hiding this comment

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

Tested this locally on Windows and it works. For anyone else wanting to test this, please remember to redis-cli flushall or delete your redis image using docker image rm redis (might need -f to force delete).

  • Set API_URL=http://localhost:3000 in your .env
  • Run docker-compose up --build
  • Run npm run develop
  • localhost:8000 in browser

localhost:3000 still shows "My first feed" for some reason but it's not there in localhost:8000

Comment on lines 25 to 34
try {
this.published = new Date(datePublished);
} catch (error) {
throw new Error(`post has invalid publication date : ${datePublished}'`);
}
try {
this.updated = new Date(dateUpdated);
} catch (error) {
throw new Error(`post has invalid date of last update: ${dateUpdated}'`);
}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you could have try and catch inside of toDate and throw there. Also, toDate checks if what's passed is already an instance of Date, I think it'd be useful to keep it.

Copy link
Member

Choose a reason for hiding this comment

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

Also, what criteria does Date follow to throw? I looked around to see how people check for invalid dates and I found some interesting suggestions.

Copy link
Contributor Author

@Silvyre Silvyre Mar 9, 2020

Choose a reason for hiding this comment

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

Made some changes in 24a4fd4, let me know what you think!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apologies for the delay. Made the requested changes in 225ef1a, please let me know what you think!

Copy link
Member

@manekenpix manekenpix left a comment

Choose a reason for hiding this comment

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

Tested locally with your branch 👍

@Silvyre Silvyre merged commit c0879c2 into Seneca-CDOT:master Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: back-end type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deal with partial/broken post content
4 participants