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

Bailey new personal max backend #619

Merged
merged 5 commits into from
Jan 27, 2024

Conversation

BaileyM96
Copy link
Contributor

Description

  1. (PRIORITY High) Bailey/Jae: Fix the New Max Personal Record award.
    The badge should just update the number next to it AND on it, and not be awarded again in the list shown below.
    Every time the record is broken though, it should still show up in the New Badges section of the person’s Dashboard

Related PRS (if any):

None

Main changes explained:

  • Added badgeCollection of only Personal Max badges to badgeOfType since badgeOfType was defined but was assigned no value.
  • Created an empty array called duplicateBadges for the duplicateBadges to be pushed into and removed without removing all Personal Max Badges.
  • Improved the removeDupBadge functionality to look for the objectId of the badge rather than just the badgeId.

How to test:

  1. check into current branch
  2. do npm install to run this PR locally
  3. Navigate to cronjobs folder→userProfileJobs→change the cronjob from '1 0 * * * ' to '* * * * *' so it runs every minute.
  4. Open MongoDb compass and find your user profile that you want to test and change personalBestMaxHrs to a value that is greater than 10→change lastWeekTangibleHrs to match the personalBestMaxHrs.
  5. do npm run build && npm start This ensures the changes for the cronjob go into affect so it will run right away.
  6. Login as your test account and Empty cache and hard reload so the changes appear on the page under Badges for the front end.

Screenshots or videos of changes:

Walkthrough of how to test the back end.
Personal Max Testing Guide.webm

The fields to change in the MongoDB database
Showing what to change in MongoDB

Note:

The badge only awards on Sundays, this testing method just helps award the badge right away to make sure the badge does not duplicate.

When awarding the badge right away it will not appear under new badges until Sunday and the count of the badges inside the report badges will not update until Sunday as well.

Copy link
Contributor

@robertoooc robertoooc left a comment

Choose a reason for hiding this comment

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

Hey @BaileyM96, I tested this pr and found everything to work well. Changing the cronjob's running period allowed the badges to remove duplicates and update the personal max hrs appropriately. It took a few page refreshes to see it work but that makes sense from the cronjob running every minute.

One thing I additionally did was comment out 527 -531 in the userProfileController.js file, this was just so caching wouldn't get in the way of the immediate update.

Only thing I would suggest is to remove unneeded console.logs.

clip.3.3.mov

Copy link
Contributor

@luisarevalo21 luisarevalo21 left a comment

Choose a reason for hiding this comment

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

Hello @BaileyM96.

I tested your PR and works as intended. Great work!
I modified, the personalBestMaxHrs and lastWeekTangibleHrs on the backend to 20. I then ran npm run build && npm start
Lastly, I did a hard refresh and showed up immediately, however, i still ran empty cache and worked as intended. The badge updated to 22 on the dashboard page and in the user's profile as well.

Screen.Recording.2023-11-26.at.7.59.12.PM.mov

Regardless, I agree with Roberto to remove any console.logs.
Overall great work!

@one-community one-community added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Dec 20, 2023
Copy link
Contributor

@ilyaflaks ilyaflaks left a comment

Choose a reason for hiding this comment

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

I have reviewed this PR and it works as intended
PR619-13hrs
Then this user beat their record. Old badge got removed and a new one (15 hrs) was awarded:
PR619-15hrs
Great work!

@@ -51,6 +51,7 @@ async function ValidatePassword(req, res) {
}

const userProfileController = function (UserProfile) {
console.log('Hello')
Copy link
Contributor

Choose a reason for hiding this comment

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

Should remove console.log statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ptrpengdev I went through and removed the remaining console logs that you mentioned :) Please let me know if i missed anything else

Copy link
Contributor

Choose a reason for hiding this comment

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

lgtm. Please do remember to pull the latest code from the development branch and resolve any conflicts. Thanks!

Copy link
Contributor

@jerryren527 jerryren527 left a comment

Choose a reason for hiding this comment

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

Hi @BaileyM96 ,

Great job on this task! Your code changes seem to work as intended. After changing personalBestMaxHrs to a value greater than 10, running the backend server, and hard refreshing, the changes to the personal max hours appear on the test account's profile page.

bailey.personal.max.demo.mov

Copy link
Contributor

@ptrpengdev ptrpengdev left a comment

Choose a reason for hiding this comment

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

Please remove the console log from the code before merging. The badge collection update functions are missing the step of adding the new earned date, which will lead to a mismatch for the count and earned dates. I have mentioned this to Jae and will create a fix for it. Other than that, the code works as expected.

src/helpers/userHelper.js Outdated Show resolved Hide resolved
@BaileyM96 BaileyM96 requested a review from ptrpengdev December 29, 2023 22:53
@Haoxiang310
Copy link

I modified my personalBestMaxHrs and lastWeekTangibleHrs to 40. The code works as intended!
backend1-PR#619(2)

backend1-PR#619(3)

backend1-PR#619(1)

Copy link

@666saofeng 666saofeng left a comment

Choose a reason for hiding this comment

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

I have examined this pull request and it functions as expected.
pr619(2)
pr619

Copy link
Contributor

@pshereen pshereen left a comment

Choose a reason for hiding this comment

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

Backend build is failing.

image

@one-community one-community dismissed pshereen’s stale review January 27, 2024 18:14

Bailey said it is good to go

@one-community one-community merged commit 560c57a into development Jan 27, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants