Order autocomplete results
Closed this issue · 11 comments
Order by occurrence (more common - higher in the list)
where do you see this feature to be adding benefit (i.e. src/components/Tune/Dialog/TextField.tsx)?
People not familiar with codebase (beginners) would greatly benefit from knowing the file name :)
Suspect file hypertuner-cloud/src/pages/Upload.tsx
code block:
<Item name='engineMake' rules={requiredTextRules}>
<AutoComplete
options={autocompleteOptions.engineMake}
onSearch={(search) => searchAutocomplete('engineMake', search)}
backfill
Correct?
ok, so it seems first hurdle to understand requirement(s) was taken.
Paraphrased in my words:
Envisaged is a global change affecting all input fields based on count of existing values in hypertuner dataset for the specific field, without considering user specific count of previously used values.
Correct?
Yes, at least this is what I was thinking when creating this issue
for example: more popular "make" -> higher in the autocomplete list in "make" field
ChatGPTs anwser:
const options = (await autocomplete(attribute, search)).map((record) => record[attribute]);
// Count the occurrences of each value
const valueCounts = {};
options.forEach((value) => {
valueCounts[value] = (valueCounts[value] || 0) + 1;
});
// Sort values by occurrence frequency (more common - higher in the list)
const unique = [...new Set(options)].map((value) => ({ value })).sort((a, b) => valueCounts[b.value] - valueCounts[a.value]);
ok, so does this code work as expected?
On a somewhat related topic, is it desired to have the same engine multiple times in the dataset under the different car maker brands using it in different models?
Best example is the famous DieselGate EA 189 engine.
This engine is found in cars from VW, AUDI, Porsche and the count of multi-brand engines is growing strong after 2003.
I haven't checked the code
Regarding other topic, it's and idea, but I'm not sure whether it's worth the time at this stage. However it could be nice to pull data from a good source
It appears to be already handled internally by the <AutoComplete />
component. Thanks @VillageR88 !