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

Extra information on Profile #974

Closed
davehakkens opened this issue Jun 2, 2020 · 12 comments · Fixed by #1040
Closed

Extra information on Profile #974

davehakkens opened this issue Jun 2, 2020 · 12 comments · Fixed by #1040

Comments

@davehakkens
Copy link
Contributor

Component infos

Description

In the profiles we need some additional information in a sidebar
Map pin: Show if profile has map pin (and link to pin. )
How-to: Show amount of how-to's created by this profile (all approved ones)
Events: Show amount of events created by this profile (all approved ones)

Page related

Will be used in :
Profiles

Mockup

profile-items-nopatreon_01
profile-items_explained_01

@BenGamma
Copy link
Contributor

BenGamma commented Jun 6, 2020

For this one IMO we should add new fields in the user model : howtoCount & eventCount to avoid having to do heavy reading on the DB (that filters from all how-to's the ones from the author) each time a user profile is displayed.
Instead Increment the counters howtoCount & eventCount each time a how-to or event is approved. These values are directly on the user's data, along with his basic informations (name- profile pic, etc).
What do you think @chrismclarke ?

@chrismclarke
Copy link
Member

Yep definitely agree with you that we need to keep specific counters for these things rather than calculating each time. I would suggest however instead of adding a lot more to the user profile we store the info either in a single userStats variable, or possibly use a subcollection so all the info sits at users/chrismclarke/stats or similar in the db.

I also think we should move the logic away from individual pages/stores (e.g. update when a user clicks to create a howto), to the database itself via triggers (i.e. when new entry is detected under howtos, read the _createdBy field and update that users stats). Actually, a good way to go about this would be to write a single trigger for all db updates (create or delete events), that keeps a single list of every entry created by that user, so all howtos, events, mappins in the same place - we can then just pull that list and filter to present any stats we want?

@BenGamma
Copy link
Contributor

BenGamma commented Jun 8, 2020

Agree with the userStats variable.

I also think we should move the logic away from individual pages/stores

You mean we will then create a firebase function that will update userStats when a db entry is created or updated ?

@chrismclarke
Copy link
Member

Exactly, so nothing needed to be called manually from the user on the webpage (which is much more prone to error), and nothing required in main platform code (all be within the functions instead)

@alromh87
Copy link
Collaborator

alromh87 commented Sep 3, 2020

Hello DB trigers for updating count when new howto/event are ready, now I will go for the display. What are your tougths on data for the frontend:

Extend user model
Create new model just for this

Note: I remember that last time I added fields to a model It caused trouble with the caching system and it would trigger big dta updates

@alromh87
Copy link
Collaborator

alromh87 commented Sep 3, 2020

In case of the first is possible I have PR ready

alromh87 added a commit to alromh87/community-platform that referenced this issue Sep 5, 2020
Shows information on user profile
- [x] Location with link to map pin
- [x] Accepted HowTos
- [x] Accepted Events

User stats are computed via firebase function triggered by database changes
@davehakkens
Copy link
Contributor Author

Neat
Could you make sure it also says How-to and Events?
afbeelding
Now it only shows the icon..

@alromh87
Copy link
Collaborator

alromh87 commented Sep 6, 2020

Thanks updated

@davehakkens
Copy link
Contributor Author

afbeelding

Howto is called event? Also should be on one line

@alromh87
Copy link
Collaborator

alromh87 commented Sep 6, 2020

Should be fixed now
Captura de pantalla de 2020-09-06 18-58-55

alromh87 added a commit to alromh87/community-platform that referenced this issue Sep 10, 2020
@chrismclarke
Copy link
Member

I've made a few changes to the code to also keep track of draft/pending as well as specific ids of events/howtos in the stats as it's cleaner from a dev perspective and figure could be useful in the future. @davehakkens - by default this shows the counts for both approved and pending howtos or events, is there a strong preference to have the number only indicate approved (one line of code to filter if that's the case), or ok to include both?

@davehakkens
Copy link
Contributor Author

no strong preference. Including draft/pending count for how-to's is also good. (there are very little of those anyway)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants