question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] Country flag doesnt change or shows on older comments

See original GitHub issue

Describe the bug It seems that if a user changes or adds their location in the profile it doesnt update their flag on older comments.

To Reproduce Steps to reproduce the behavior:

  1. Go to how-to
  2. Leave a comment
  3. Change location
  4. Check the comment
  5. Leave a new comment to see the difference

Expected behavior Ideally, this is in sync across the entire platform. Change your location (flag) > see the change everywhere. in howto, research, comments etc. (This functionaity does seem to work in user profiles. Change location and the flag changes there)

Screenshots Same username, different location afbeelding

Additional context:

The Community Platform is built on top of a document orientated database called FireStore. As a NoSQL data store it is not simple to perform join queries across multiple collections, for example Howto articles and Users.

Existing behaviour:

  1. We have the User entity, this is where a user can define their location, which we use to render a flag next to their username.
  2. We display the user name in multiple places across the site. Each query/read of a User document is considered a billable unit by Firebase.
    To reduce the number of billable operations we copy the location data into each of the following:
    1. Howto article
    2. Howto comment
    3. Research article
    4. Research comment

The implications of this approach are that each time a User changes their location we need to update the location data in each of the documents generated by that User.

The current implementation for syncing this content, is run as a Cloud function triggered by changes in Firestore. Code: https://github.com/ONEARMY/community-platform/blob/master/functions/src/userUpdates/index.ts#L16-L17

The drawbacks with the current approach are:

  1. Each time we add the username location to a new place in our document store we need to extend our sync mechanism to ensure it stays up to date
  2. The update method could fail and we have low visibility into this.
  3. Duplicates the User model data structure in multiple places across the system. This means if we made a change to the User data structure we would have to remember to update; the sync mechanism, all existing documents and UI logic.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
danitrodcommented, Jul 23, 2022

So as discussed on Slack, the current comments structure doesn’t allow for queries such as “all comments for which the userId is X”, which prevents us to update comments for an updated user (unless we query for all howto’s and manually filter, which is inefficient).

The proposed solution is to add to the user info an array of all the howto (and research) id’s where they commented. We still have to discuss how to apply this modification to every existing user. What I’m thinking is creating a one-time running function to update all the users. I’ll be happy to work on this @eliasvelardezft if you’re not able to

1reaction
eliasvelardezftcommented, Jun 16, 2022

@davehakkens hi!! Sorry for the late reply, I’ve been really really busy and haven’t got the time to work on the bug. I started reading through the code when I said I would fix it and I couldn’t easily find the solution and then I simply couldn’t work on it. I’ll try to solve it this weekend, if I can’t I’ll ask for help haha. As for the bounty you’re correct, I hadn’t seen the message. As I said before in the issue comments, I don’t want the bounty! I really like onearmy’s projects (specially project kamp) so I’d like to contribute for free

Read more comments on GitHub >

github_iconTop Results From Across the Web

How many times countries have changed their flag [OC] [4011 ...
I feel like the U.S. "official flag changes" are a really different caliber than that of other nations - it's the same basic...
Read more >
15 Country Flags and their Hidden Meanings You Can't Un-see
2. Austria. This flag is one of the few that are older than the Union Jack, dating back to 1230. The legend that...
Read more >
The Visual Meaning Behind 24 of the World's Most Iconic Flags
The Union Jack of the United Kingdom combines aspects of three older national flags and was adopted in 1801. Displaying the flag upside...
Read more >
Iran is calling for the U.S. to be thrown out of the World Cup ...
The flag change was made to show support for Iran's female-led protest movement, the U.S. Soccer Federation said. Ahmad Nourollahi of Iran ...
Read more >
Iran calls for US to be kicked out of 2022 World Cup ... - CNN
Iran state media has called for the US to be kicked out of the 2022 World Cup after US Soccer changed the country's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found