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

Mismatch between graphql data and whereisip #148

Closed
MohamedElmdary opened this issue Jan 9, 2024 · 7 comments
Closed

Mismatch between graphql data and whereisip #148

MohamedElmdary opened this issue Jan 9, 2024 · 7 comments
Assignees
Labels
type_bug Something isn't working
Milestone

Comments

@MohamedElmdary
Copy link
Member

Naming of country czechia comes from whereisip however graphql return another naming Czech Republic

image

image

@samaradel
Copy link

Similar case for United States and United Kingdom
image
image

@sameh-farouk
Copy link
Member

sameh-farouk commented Feb 4, 2024

Our squid processor uses this API https://restcountries.com/v2/all to initialize the countries table. country names could have differences between different APIs. can we show the country's name in UI but rely instead on the country code for any filtration etc?

@sameh-farouk
Copy link
Member

sameh-farouk commented Feb 4, 2024

There is a v3 of the API that we are using in Graphql (currently we are using v2).
The name becomes an object that contains a common name (looks like what you want) and an official name (similar to the one we are using ATM). For example United Kingdom name-value looks like this

{ 
common": "United Kingdom",
"official": "United Kingdom of Great Britain and Northern Ireland",
...
}

and for Czechia

{
common": "Czechia",
"official": "Czech Republic",
...
}

so, I can switch from v2 to v3 in Graphql init script and use the common name. This would solve the reported instances from @MohamedElmdary and @samaradel but I am not sure if there is an easy way to retrieve all country names from the whereisip API to verify that we won't have another mismatch.

@Omarabdul3ziz
Copy link
Contributor

hi, i was debugging an issue on gridproxy threefoldtech/tfgrid-sdk-go#699 it shows a broken region filter for nodes.

how the region filter work on the proxy?
we join the node table with the country table based on the condition node.country = country.name

but looks like there is an inconsistency between the data returned from the graphql the common short name is the one used on the node table but the official full name is used on the country table
image

so that is why /nodes?region=americas doesn't list the united statesd nodes. same with the United Kingdom and Czechia

@sameh-farouk
Copy link
Member

sameh-farouk commented Feb 20, 2024

Update:
PR is ready for review.

It is based on the changes I mentioned in my previous comment.

As I mentioned in the PR description, this is a temporary, easy workaround fix.
However, although it should resolve the mismatch for the reported countries, it is important to note that this fix may not work for all countries as the process of joining data from different APIs based on country names is not reliable.

To elaborate, in our squid processor, we fetch cities from the repository available at https://raw.githubusercontent.com/shivammathur/countrycity/master/data/geo.json and countries from the https://restcountries.com/ API. We then join these data based on the country name. Similarly, in the Gridproxy, we fetch node data from the chain and county data from GraphQL and join it based on the country name.

This process is not always accurate as there are often alternative spellings for country names. Hence, unless you are using the same data source, it's not guaranteed to find a match.

To properly resolve this issue, I suggest using the same API (if possible), or a more unique identifier such as country code. Also, we could sort to craft our data source and use it.
However, this would require changes in multiple services. hence I'm offering this patch as a temporary solution for now.

@sameh-farouk sameh-farouk self-assigned this Feb 20, 2024
@sameh-farouk sameh-farouk added the type_bug Something isn't working label Feb 20, 2024
@sameh-farouk sameh-farouk added this to the 3.0.0 milestone Feb 20, 2024
@sameh-farouk sameh-farouk moved this to Pending review in 3.13.x Feb 20, 2024
@sameh-farouk sameh-farouk moved this from Pending review to Pending Deployment in 3.13.x Feb 22, 2024
@sameh-farouk sameh-farouk moved this from Pending Deployment to In Verification in 3.13.x Feb 26, 2024
@sameh-farouk
Copy link
Member

sameh-farouk commented Mar 10, 2024

All is good now? @MohamedElmdary @samaradel @Omarabdul3ziz
Patch on dev, qa and test networks

@Omarabdul3ziz
Copy link
Contributor

yes all good now on 4 nets, thanks
image

@sameh-farouk sameh-farouk moved this from In Verification to Done in 3.13.x Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type_bug Something isn't working
Projects
No open projects
Status: Done
Development

No branches or pull requests

4 participants