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

feat: verified icon in usernames #1205

Merged
merged 7 commits into from
Feb 17, 2022

Conversation

danitrod
Copy link
Collaborator

PR Checklist

  • - Latest master branch merged
  • - PR title descriptive (can be used in release notes)

PR Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Adding verified icon to usernames in howto listings, howto pages, howto comments, events, research listings and research pages.

The approach chosen was to create a fetchAllVerifiedUsers method in the userStore, which queries the database for all users who meet the badges.verified == 1 condition and stores the list in a verifiedUsers prop. Based on that list, each component that displays usernames basically checks if the username is on the list to display a badge along.

Note: I changed the value type of badges.verified from boolean to number, having the number be 0 or 1. The reason is that boolean was causing problems with Dexie as booleans are not indexable (ref: https://stackoverflow.com/a/56661425/10736715). I added a comment explaining this in the model definition.

Git Issues

Closes #1163

@danitrod danitrod added the Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview label Aug 12, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Aug 12, 2021

Visit the preview URL for this PR (updated for commit 27bf097):

https://onearmy-next--pr1205-verified-everywhere-qog5kwt8.web.app

(expires Sat, 19 Mar 2022 00:34:51 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@thisislawatts
Copy link
Collaborator

👋 @danitrod would you be able to rebase this PR to resolve merge conflicts?

@danitrod
Copy link
Collaborator Author

Sure @thisislawatts, done!

@cypress
Copy link

cypress bot commented Oct 20, 2021



Test summary

70 0 0 0Flakiness 2


Run details

Project onearmy-community-platform
Status Passed
Commit 5658585
Started Oct 21, 2021 12:20 AM
Ended Oct 21, 2021 12:28 AM
Duration 07:30 💡
OS Linux Ubuntu - 20.04
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

sign-up.spec.ts Flakiness
1 [Sign-up - new user] > sign in as new user
sign-in.spec.ts Flakiness
1 [Sign in] > [By Anonymous]

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@danitrod
Copy link
Collaborator Author

I see tests are failing, will have a look at that later today

@danitrod
Copy link
Collaborator Author

Alright, looks like all set now!

@@ -126,6 +129,9 @@ export class Howto extends React.Component<
<>
<HowtoDescription
howto={activeHowto}
verified={this.injected.userStore.verifiedUsers.some(
user => user.userName === this.store.activeHowto?._createdBy,
)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: Can we move the verified state to the HowTo document rather than perform this look up?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't recall any specific reason why I did this, it's been a while but maybe I just didn't think it through enough. If we move this logic to the store and have the verified state in every HowTo doc, it would certainly be a lot more efficient and only perform the search once 😅

@thisislawatts
Copy link
Collaborator

@danitrod I missed the original conversation around this feature.

Did we consider how fetchAllVerifiedUsers may affect the charges incurred by the Project? I understand that Firebase charges for each read operation on a record.

So this change would a new query of N records to the following routes:

  1. Events listing
  2. Howto listing
  3. An individual howto page
  4. Research listing
  5. Individual research page

Things I either don't know or understand:

  1. FireBase caching means we can make repeated queries to the DB without incurring additional charges
  2. There are only a low number of verified users so this is not a significant issue
  3. This approach has already been approved with full awareness of the cost implications

@danitrod
Copy link
Collaborator Author

@danitrod I missed the original conversation around this feature.

Did we consider how fetchAllVerifiedUsers may affect the charges incurred by the Project? I understand that Firebase charges for each read operation on a record.

So this change would a new query of N records to the following routes:

1. Events listing

2. Howto listing

3. An individual howto page

4. Research listing

5. Individual research page

Things I either don't know or understand:

1. FireBase caching means we can make repeated queries to the DB without incurring additional charges

2. There are only a low number of verified users so this is not a significant issue

3. This approach has already been approved with full awareness of the cost implications

I don't have the basis to answer that right now as well, would have to study a bit more on how Firebase works. I don't remember if I talked with Chris about the implications on charges for this logic. Sorry, been some rough few months over here. Hopefully at the beginning of next year I'll be able to dedicate some more time into the project and help figuring this out.

@thisislawatts
Copy link
Collaborator

Thanks for the speedy response @danitrod, of course look after yourself first. This discussion can wait 🤗

@chrismclarke
Copy link
Member

chrismclarke commented Feb 2, 2022

I have a good feeling this will finally be the week to unblock this PR!
As discussed on the calls and slack message last week, the blocking issue on this was how best to keep a shortlist of all user badges, as querying across all users is both tricky and inefficient. This is a common problem so decided best to come up with a general solution the make it easier for storing similar aggregations, via an aggregations db endpoint and set of backend functions

This just leaves a few small tasks

  • Add db bindings for aggregations system ( Feat/db aggregations #1446)
  • Resolve conflicts (mostly just minor import issues)
  • Small refactor to point to aggregations endpoint
  • Test and release

I'm working on the DB bindings now and will link the relevant PR when open

@chrismclarke chrismclarke mentioned this pull request Feb 2, 2022
6 tasks
@chrismclarke chrismclarke self-assigned this Feb 2, 2022
@thisislawatts thisislawatts mentioned this pull request Feb 5, 2022
6 tasks
@chrismclarke chrismclarke changed the base branch from master to pr/1205-rebased February 17, 2022 04:01
@chrismclarke chrismclarke changed the title Verified icon in usernames feat: verified icon in usernames Feb 17, 2022
@chrismclarke chrismclarke merged commit ea109aa into ONEARMY:pr/1205-rebased Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mod: Events 🎉 Mod: HowTo 📰 Mod: Research 🔬 Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display verified icon in username
3 participants