Skip to content

Add combined ID and username search#10

Open
ziemek99 wants to merge 2 commits intoZverik:masterfrom
ziemek99:search-by-id
Open

Add combined ID and username search#10
ziemek99 wants to merge 2 commits intoZverik:masterfrom
ziemek99:search-by-id

Conversation

@ziemek99
Copy link
Contributor

@ziemek99 ziemek99 commented Oct 7, 2025

Closes #8 😁

Now for every user's query the frontend makes up to two API requests, one (always) for usernames and one (only if it's a valid number) for UID. When sending two API calls, both must complete before showing the results. Any found UID is displayed on top of the results in bold. In some cases a UID can be a part of or the entire username, so it's possible for UID to show up in results of both API calls. The frontend protects against that by always removing the queried UID from the username API results, so the only way the UID can show up on the page is from the UID API result.

Drive-by fixes:

  • API no longer returns empty username history for UIDs that don't exist in the database. It was necessary before starting any frontend work since it fooled the frontend into thinking that any queried UID always existed and "No users found" message had no chance to occur.
  • In order to be consistent with OpenStreetMap API, if you provide Who's That API a UID with leading zeros, they get trimmed internally and any results are now returned without them.
  • Empty query field now triggers an early exit within updateAutocomplete(). A side effect is that now after clearing the field the site keeps last search results instead of showing the blank page, but I guess it's a fair price for reducing unnecessary API calls.

Drive-by fix required for implementing combined search by ID and name
in frontend. Random digits no longer return a fake ID search result.
Leading zeros in input ID are now trimmed to match OSM API behavior.
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

Successfully merging this pull request may close these issues.

Search: Add option to search by uid

1 participant