ONEARMY / community-platform

A platform to build useful communities that aim to tackle global problems
https://platform.onearmy.earth
MIT License
1.14k stars 386 forks source link

[bug] Inconsistent flag rendering in how-tos #3131

Open darigovresearch opened 9 months ago

darigovresearch commented 9 months ago

Describe the bug Flags are not all the same for our profile, this could be happening for other users

To Reproduce Steps to reproduce the behaviour:

  1. Go to here
  2. See the flags on how-tos we've written do not match
  3. or see the screenshot

Expected behaviour They should all be the same flag

Screenshots image

Additional context They should all be the UK flag as we're based in London, UK

goratt12 commented 9 months ago

This is happening due the change in the creatorCountry field in the howto collection from _creatorCountry to creatorCountry. The change occurred on Sep 15, 2020 (after the upload of the gray flagged HowTo's) - in this commit

In order to solve this issue, we need to scan the howto collection and change the field _creatorCountry to creatorCountry.

iSCJT commented 9 months ago

I've checked the database and the _creatorCountry field isn't present for those howto's. Not sure whether the migration went wrong or the country wasn't set at the time the migration happened.

I'll look at writing a script to reset all the howto's to their creators current country. In the meantime if you want a quick fix @darigovresearch, I think changing your location to a different country, waiting a minute and then changing it back to your actual location should probably update them all.

davehakkens commented 9 months ago

I think some locations might have been set using the map. If user has "want to get started" pin (we had a few bugs with that in the past)

pizzaisdavid commented 3 months ago

The link in the original post seems to not work exactly anymore, as filtering by author seems to have been be removed. But you can visit https://community.preciousplastic.com/u/darigov-research then the contributions tab, and then open all three howtos and see that there are still different flags.

I second what @iSCJT said. The user's location is stored both in the user profile data and the data of the howto (a design decision to optimize reads) and probably at one point the data didn't get synchronized, either because that functionality didn't exist yet or a bug.

mariojsnunes commented 3 months ago

filtering by author seems to have been be removed.

Note this change: https://github.com/ONEARMY/community-platform/pull/3415 (same for howtos and questions)

goratt12 commented 2 months ago

I wrote a script that will finish the migration and solve this issue https://github.com/goratt12/howtos-migration Tested on the testing environment 👍

pizzaisdavid commented 2 months ago

@goratt12 Nice!

I didn't look at it in detail.

In my opinion, it would probably best to try to add it into the codebase, for example, copying an already existing one-time migration: https://github.com/ONEARMY/community-platform/blob/master/functions/src/database/updates.ts

I would propose introducing a folder in the database folder called migrations, and then calling your thingy something like 2024_07_07_whatever

But a disclaimer: so far, I didn't figure out how to trigger it.

goratt12 commented 2 months ago

@pizzaisdavid That is a good idea! I will create a PR and insert this code as a function. we can run it using HTTP trigger