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(`
|
query := fmt.Sprintf(`
|
||||||
with search_results as (
|
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
|
from foodfix
|
||||||
inner join food f on f.food == word
|
inner join food f on f.food == word
|
||||||
where word MATCH ?
|
where word MATCH ?
|
||||||
)
|
)
|
||||||
select %s, score
|
select %s, score
|
||||||
from search_results
|
from search_results
|
||||||
group by food
|
where rn = 1
|
||||||
order by score asc, date desc
|
order by score asc, date desc
|
||||||
limit %d
|
limit %d
|
||||||
`, foodColumns, Settings.SearchLimit)
|
`, foodColumns, Settings.SearchLimit)
|
||||||
|
@@ -106,6 +106,7 @@
|
|||||||
function setInputVal(food: main.Food) {
|
function setInputVal(food: main.Food) {
|
||||||
name = food.food;
|
name = food.food;
|
||||||
per100 = String(food.per100);
|
per100 = String(food.per100);
|
||||||
|
amount = String(food.amount);
|
||||||
hiLiteIndex = null;
|
hiLiteIndex = null;
|
||||||
foodSearch = [];
|
foodSearch = [];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user