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

Country should default to current, not previous country #9

Closed
AnnikaStein opened this issue Mar 18, 2024 · 8 comments
Closed

Country should default to current, not previous country #9

AnnikaStein opened this issue Mar 18, 2024 · 8 comments
Assignees

Comments

@AnnikaStein
Copy link

If a person gets a subid, e.g. for changing region, there would be multiple regions that could be of interest: the former one or the current one, under which they should be ranked.

I now have a case where the API returns country 'CN' while the tsv-export of the database returns 'DE', the reason probably coming from handling the subid https://github.com/thewca/worldcubeassociation.org/blob/main/app/views/persons/_details.html.erb#L12 differently.
Could you look into this? We are using your API for a fresh federal state ranking (https://github.com/AnnikaStein/WCA-German-State-Ranks) that everyone can enter independent of the country on the WCA page, hence we sometimes have some person data with a foreign country, and in rare cases, their country changed in the past. We would like to be inclusive, and not require any condition a priori here, some people live there, study there, or have any other affiliation with a federal state that is independent of citizenship.

Example: https://annikastein.github.io/WCA-German-State-Ranks/pages/by-state_bw.html which is generated from the API writes 2018XIAO03 as 'CN', while the Website writes 'DE' as country code, same for the aforementioned tsv. 'DE' would be what we want to grab, not the previous country iso that refers to the person's subid.

It would be great to have this data being written into the country string when using person by id (https://wca-rest-api.robiningelbrecht.be/#tag/person/operation/getPersonById). Thank you and greetings!

@robiningelbrecht
Copy link
Owner

@AnnikaStein Problem is that the DB I use to generate this API only has this data:
image
So there is no way to know which one is "the most recent" as far as I can see...

@AnnikaStein
Copy link
Author

AnnikaStein commented Mar 19, 2024

@robiningelbrecht
I see, for this example it would be subid 1 which is relevant, and I would back this claim for general cases with the following piece of code: https://github.com/thewca/worldcubeassociation.org/blob/main/app/models/anonymize_person.rb#L85
where previous persons is everything, but not the subid 1, i.e. the "current" would be subid 1.

EDIT:
There is also this update function, which assigns the subids (old -> higher subid): https://github.com/thewca/worldcubeassociation.org/blob/main/app/models/person.rb#L88-L104

@robiningelbrecht
Copy link
Owner

@AnnikaStein so basically I can just add WHERE subid = 1 to my query if I understand correctly?

@AnnikaStein
Copy link
Author

That's how I would understand it also, yes

@robiningelbrecht
Copy link
Owner

@AnnikaStein Pushed fix, files are building. Will take a few hours

@AnnikaStein
Copy link
Author

Cool, thank you for the quick fix!

@AnnikaStein
Copy link
Author

Nice, thanks again! Just updated on our end as well.

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

No branches or pull requests

2 participants