-
Notifications
You must be signed in to change notification settings - Fork 0
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
Resolves Issue #10 (#32) - Estimate Next Purchase Date #55
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.
Major props to refactoring and setting up all these calculations! I'm hoping we can have a small demo this Sunday since there is quite a bit going on with the calculations and looks pretty good
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.
already left my review but i guess changing the title removed it...
.update({ datePurchased }); | ||
console.log(dbItems); | ||
// Checks if a purchase date already exists - if not, creates a purchased date and increments # of purchases - if so, also sets the most recent purchase estimate, the most recent purchase interval and the calculated date of the next purchase | ||
const handleChange = (e, item) => { |
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.
Awesome! I love that you're passing in the item
here. This makes it really easy to keep track of which item they selected.
let latestInterval = Math.floor( | ||
(datePurchasedInSeconds - lastDatePurchased.seconds) / HOURS24 | ||
); | ||
let db = firebase.fb.firestore(); |
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.
I'm curious, do you think that this could be defined outside of this function? That way we don't have to create it every time this handler function is called.
(datePurchasedInSeconds - lastDatePurchased.seconds) / HOURS24 | ||
); | ||
let db = firebase.fb.firestore(); | ||
let nextPurchaseDate = calculateEstimate( |
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.
👏 I love that this logic is split up into a separate function. It helps me follow what's going on!
let db = firebase.fb.firestore(); | ||
db.collection(token) | ||
.doc(e.target.value) | ||
.update({ datePurchased, numOfPurchases: item.numOfPurchases + 1 }); |
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.
If there is no datePurchased
, will numOfPurchases
always be 0, so we always send 1 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.
🏅 Very good PR!
The best part about this PR is how well you outlined your intent of the PR in the description. I'll be mentioning this on our next call as a model way to do it!
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.
Great job, y'all! This is amazing work.
src/List/ItemList.js
Outdated
.doc(e.target.value) | ||
.update({ datePurchased }); | ||
console.log(dbItems); | ||
// Checks if a purchase date already exists - if not, creates a purchased date and increments # of purchases - if so, also sets the most recent purchase estimate, the most recent purchase interval and the calculated date of the next purchase |
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.
Small note, move this into a multi-line comment instead of making the whole thing one line. Harder to read this way!
Issue #32
Task
The main purpose of this issue was to calculate the number of days until the next purchase date and store it in the database
Actions
Notes
The date of the next purchase is calculated by a provided script - estimates.js
It's largely possible this solution could be heavily refactored, but due to time constraints, we're comfortable submitting what at least appears to be working successfully. :-)