Duplicate typescript search item in languages field for resource search by language
Matt-st opened this issue · 7 comments
Bug Report
What is the current behavior?
The current behavior is that 2 items show up for the language "typescript" when searching by language.
What is the expected behavior?
There should only be one option that shows up in the languages search field for "typescript".
What steps did you take to get this behavior?
I went to this page and typed in "typescript" which returns 2 results as you can see below.
Additional Info
Operating System
Browser
google chrome
Is This A Third-Party Issue?
Don't know
Screenshots
After looking into it a bit more I believe that the list of languages which the UI is using for this search field are produced from the resources api specifically here languages.py.
I believe the solution is to clean up our database table that holds the languages. Additionally to safeguard against this in the future we could add some DeDuplication constraints on the languages table such that same words with different capitilization are not allowed to be entered into the languages table.
@Matt-st I just fixed the issue with the duplicate typescript language in prod. Do you want to take a stab at fixing the API to add a deduplicate constraint?
@aaron-suarez can I work on this issue as it seems inactive for awhile
@aaron-suarez need a bit of help so I was thinking converting list inside get_languages to a set will help 🤔 but regarding that not allowing addition of different capitalisation in table for same language where is that part?
@king-11 This function is the part that gets the list of languages from the request (specifically a resource creation or resource modification request) and formats it in a way that it can be added to the Resource.
https://github.com/OperationCode/resources_api/blob/main/app/api/routes/helpers.py#L18-L32
We'll need to add de-duplication checks in there