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(user): new function to compute unique days within hours. #16077
fix(user): new function to compute unique days within hours. #16077
Conversation
@kennethlumalicay updated the pull request. |
75f4b92
to
004cdf9
Compare
@kennethlumalicay Awesome! Thanks for making this pull request and documenting your reasoning behind these changes. @BerkeleyTrue could you QA this and if it's ready, merge it? |
@kennethlumalicay this section is already well tested. Can you add tests for the new function you added in |
What is the bases of this change?
If it isn't being used please remove it and the associated tests |
Hi, I'll work on this again when I get the time I've been quite busy with stuff so this would be on hold for now. :) If anyone wants to grab/remake the code and make a PR that's fine too. Thanks for understanding. PS: The EST change was based on quincy saying we could just normalize the time to EST but I didn't do that so I just used it as default. |
@kennethlumalicay OK - this has been an open issue for some time and it feels like this is the closest anyone has come to fixing it. How soon would you have time to finish this PR up? |
I should be able to work on this after thanksgiving. |
@kennethlumalicay thanks for the update. Let me know if you get stuck |
@kennethlumalicay Thanks for your continued help with this. We're excited to get this live, so let us know when it's ready for QA :) |
@kennethlumalicay updated the pull request. |
d53ccea
to
434f6ed
Compare
@kennethlumalicay updated the pull request. |
@BerkeleyTrue Hi. I updated the PR and I'm getting conflicting files. Idk what it means or how to solve it. Thanks! @QuincyLarson I just wanted to give back to the community and I chose the oldest issue with help wanted. Hope this works without any issue. :) |
@kennethlumalicay The lodash chaining is removed upstream of your commit so that babel-plugin-eslint can be used. You'll need to rewrite your function so that it does not use lodash chaining see: https://medium.com/making-internets/why-using-chain-is-a-mistake-9bc1f80d51ba for some examples of this. |
434f6ed
to
aed27dc
Compare
@kennethlumalicay updated the pull request. |
@kennethlumalicay Thanks for updating your PR. It looks like there are still merge conflicts. Could you resolve these, then let @BerkeleyTrue know when you're ready for him to take another look at your pull request? |
@QuincyLarson what actions do I need to take to resolve the conflicting files? Seems like the user-stats.js changed since I forked the code, should I do pull --rebase on upstream or will I lose my commit if I do that? I have already removed lodash chaining as @BerkeleyTrue said. |
@kennethlumalicay Yes you'll need to do a rebase. Although daunting at first, being able to pull off a successful rebase will make you a much more powerful dev wizard. First you'll need to check that your local copy of the staging branch is up to date Once this is accomplished checkout this branch branch again (the branch with your changes) and then enter the rebase command: This will replay your commit on top of the lastest commits in staging. You should see a message stating that there are conflicts that must be resolved in order to complete the rebase. Open the file with the conflicts in your editor of choice. Edit the file and save. Add your new changes to staging (i.e. Once your are satisfied with your changes and have added them to staging enter the command |
@kennethlumalicay updated the pull request. |
aed27dc
to
46383dd
Compare
@BerkeleyTrue done. Thanks for the very detailed instruction! 👍 |
✨ Nice work!! |
@kennethlumalicay I'm a bit late to the party, but I wanted to congratulate you as well. This should significantly reduce the corner cases where a campers' streak seems off. Thank you for helping improve this logic! |
@QuincyLarson no problem, I'll check out more issues when I get the time. 👍 |
Pre-Submission Checklist
staging
branch of freeCodeCamp.fix/
,feature/
, ortranslate/
(e.g.fix/signin-issue
)npm test
. Usegit commit --amend
to amend any fixes.Type of Change
Checklist:
Closes #7925
Description
Made a new function to prep unique days based on hours from the previous data instead of startOf day.
Then
startOf('day')
and then.uniq()
to avoid duplicates. This method turns all timestamp's hours into 12am(?) of that day thus difference in days within timestamps can only be integers.Now
Timestamps are sorted then reduced. If the data is over hoursDay(24) of the previous data it is pushed into the accumulator. This method keeps the hours of the timestamps.
Calculations uses hoursBetween(24) instead of daysBetween(1.5).
Calculations are done by taking 12am of the latest day and checks if the previous timestamp is within 24 hours.
Also changed default to EST.
Findings
hoursBetween 24 is more accurate but despite being accurate it still has a leeway between timestamps as the timestamp's difference is calculated using the previous timestamp's 12am and the time of current timestamp and checks if it's within 24 hours.
e.g.
2017-11-02T23:00:00.000
and2017-11-01T08:00:00.000
would still count as a streak despite being 39 hours apart because we check using2017-11-02T00:00:00.000
and see if2017-11-01T08:00:00.000
is still within 24 hours.@QuincyLarson
PS: I didn't delete prepUniqueDays although it's not being used anymore. Also haven't made unit tests.