Skip to content

Issue 239 stop old due dates #269

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

clivemeister
Copy link
Contributor

Short change to check the date that has been parsed out of a new promise by Sherlock as the date the commitment is to be completed by. If the date is "too old" (currently coded as more than a year ago), the date is rejected, and we carry on as if no date were parsed out.

@codeclimate
Copy link

codeclimate bot commented Sep 4, 2018

Code Climate has analyzed commit 7982bdf and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1
Clarity 1

The test coverage on the diff in this pull request is 50.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 21.1% (0.1% change).

View more on Code Climate.

let { eventTitle, isAllDay, startDate } = parseSherlock({ text, timezone })

if ( moment(startDate).isBefore(moment().subtract(1, 'years')) ) {
log.debug('Caught and fixed promise with old parsed start date of:', startDate)
Copy link

Choose a reason for hiding this comment

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

Line 36 exceeds the maximum line length of 80.

Copy link
Member

Choose a reason for hiding this comment

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

good idea to log this, we should probably have it as a warn with a more succinct message like 'parsePromise rejected past due date:'


if ( moment(startDate).isBefore(moment().subtract(1, 'years')) ) {
log.debug('Caught and fixed promise with old parsed start date of:', startDate)
startDate = null; // clear startDate if more than a year ago
Copy link

Choose a reason for hiding this comment

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

Extra semicolon.

Copy link
Member

Choose a reason for hiding this comment

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

👍

@codecov
Copy link

codecov bot commented Sep 4, 2018

Codecov Report

Merging #269 into master will increase coverage by 0.05%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #269      +/-   ##
==========================================
+ Coverage   21.06%   21.12%   +0.05%     
==========================================
  Files          28       28              
  Lines         674      677       +3     
==========================================
+ Hits          142      143       +1     
- Misses        532      534       +2
Impacted Files Coverage Δ
lib/parse/promise.js 79.31% <50%> (-5.31%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c28a78...28073c7. Read the comment docs.

@autorebase autorebase bot added autorebase and removed autorebase labels Sep 8, 2018
Copy link
Member

@chrisbutler chrisbutler left a comment

Choose a reason for hiding this comment

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

a few changes, plus the linting stuff

let { eventTitle, isAllDay, startDate } = parseSherlock({ text, timezone })

if ( moment(startDate).isBefore(moment().subtract(1, 'years')) ) {
log.debug('Caught and fixed promise with old parsed start date of:', startDate)
Copy link
Member

Choose a reason for hiding this comment

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

good idea to log this, we should probably have it as a warn with a more succinct message like 'parsePromise rejected past due date:'

const { eventTitle, isAllDay, startDate } = parseSherlock({ text, timezone })
let { eventTitle, isAllDay, startDate } = parseSherlock({ text, timezone })

if ( moment(startDate).isBefore(moment().subtract(1, 'years')) ) {
Copy link
Member

Choose a reason for hiding this comment

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

so, i think that this check/override should only happen when we create the the promise, so that this function still gives us what we expect

also, this will need to be a timezone aware check because we're going to change the criteria to reject any date that is in the past i.e. < now (before, at a 1 year scale, being within 24 hours wouldn't really matter)

this should happen before that closeOfBusiness check so that the default will be applied (and you can look at that function for timezone handling)


if ( moment(startDate).isBefore(moment().subtract(1, 'years')) ) {
log.debug('Caught and fixed promise with old parsed start date of:', startDate)
startDate = null; // clear startDate if more than a year ago
Copy link
Member

Choose a reason for hiding this comment

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

👍

@autorebase autorebase bot added autorebase and removed autorebase labels Sep 8, 2018
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.

2 participants