-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[Whatpulse] badge for a user and for a team #8466
Conversation
|
Thanks for the review @chris48s. I will mark this PR as a WIP until I’m done with the corrections. |
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 a little late to this party but left a few inline comments
services/test-validators.js
Outdated
) | ||
|
||
const isHumanized = Joi.string().regex( | ||
/\d* (second|seconds|minute|minutes|hour|hours|day|days|month|months|year|years)/ |
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.
\d*
will match zero digits. Think we want \d+
to require one or more.
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.
https://day.js.org/docs/en/durations/humanize
In these examples they mention that the result of ‚humanize()’ can sometimes be for example ‚a day’.
I used an asterisk here on purpose :))
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.
OK - got it. Thanks 👍
Basically, we don't want ' second'
to be valid. How about we make it [0-9a-z]+
. rather than \d*
. That should ensure there is some value there and I think that should catch all the cases we care about.
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.
/\d* (second|seconds|minute|minutes|hour|hours|day|days|month|months|year|years)/ | |
/[0-9a-z]+ (second|seconds|minute|minutes|hour|hours|day|days|month|months|year|years)/ |
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.
Regex modified
@chris48s I think that all that we discussed regarding this PR is already implemented :) |
nice one - cheers 👍 |
closes #8356
WhatPulse API docs: https://help.whatpulse.org/api/web-api/
user: https://api.whatpulse.org/user.php?user=jerone&format=json
team: https://api.whatpulse.org/team.php?team=dutch%20power%20cows&format=json
user as user id, uptime

http://localhost:8080/whatpulse/uptime/user/179734
user as user name, upload

http://localhost:8080/whatpulse/upload/user/jerone
user as user name, download

http://localhost:8080/whatpulse/download/user/jerone
team as team id, keys

http://localhost:8080/whatpulse/keys/team/1295
team as team name, clicks

http://localhost:8080/whatpulse/clicks/team/dutch%20power%20cows
team as team name, keys - category from Ranks

http://localhost:8080/whatpulse/keys/team/dutch%20power%20cows?rank
invalid category name (not one of the options from the dropdown for the WhatPulse's badge modal)

http://localhost:8080/whatpulse/UpTIMe/user/jerone
incorrect user name (the response from the WhatPulse's API does not contain the Joi-required fields)

http://localhost:8080/whatpulse/uptime/user/jeroneeeeeeeeee