Ensure only last rows are queried for search
This commit is contained in:
@@ -68,14 +68,15 @@ func (s *FoodService) GetLastPer100(name string) ([]FoodSearch, error) {
|
||||
|
||||
query := fmt.Sprintf(`
|
||||
with search_results as (
|
||||
select word, score, f.rowid, f.*
|
||||
select word, score, f.rowid, f.*,
|
||||
row_number() over (partition by f.food order by score asc, date desc) as rn
|
||||
from foodfix
|
||||
inner join food f on f.food == word
|
||||
where word MATCH ?
|
||||
)
|
||||
select %s, score
|
||||
from search_results
|
||||
group by food
|
||||
where rn = 1
|
||||
order by score asc, date desc
|
||||
limit %d
|
||||
`, foodColumns, Settings.SearchLimit)
|
||||
|
@@ -106,6 +106,7 @@
|
||||
function setInputVal(food: main.Food) {
|
||||
name = food.food;
|
||||
per100 = String(food.per100);
|
||||
amount = String(food.amount);
|
||||
hiLiteIndex = null;
|
||||
foodSearch = [];
|
||||
}
|
||||
|
Reference in New Issue
Block a user