mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-26 11:36:20 +00:00
siempre conseguir ultima entry para busqueda
This commit is contained in:
parent
a1faa4f73c
commit
26cb7b80e3
1 changed files with 4 additions and 2 deletions
|
@ -7,12 +7,14 @@ export const load: PageServerLoad = async ({ url }) => {
|
||||||
const query = url.searchParams.get("q");
|
const query = url.searchParams.get("q");
|
||||||
let results: null | { ean: string; name: string; imageUrl: string }[] = null;
|
let results: null | { ean: string; name: string; imageUrl: string }[] = null;
|
||||||
if (query) {
|
if (query) {
|
||||||
const sqlQuery = sql`select p.ean, p.name, p.image_url as imageUrl from precios_fts f
|
const sqlQuery = sql`select p.ean, p.name, p.image_url as imageUrl, p.fetched_at from precios_fts f
|
||||||
join precios p on p.ean = f.ean
|
join precios p on p.ean = f.ean
|
||||||
where f.name match ${`"${query}"`}
|
where f.name match ${`"${query}"`}
|
||||||
group by p.ean;`;
|
group by p.ean
|
||||||
|
having max(p.fetched_at);`;
|
||||||
results = db.all(sqlQuery);
|
results = db.all(sqlQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { query, results };
|
return { query, results };
|
||||||
};
|
};
|
||||||
|
// order by p.fetched_at
|
||||||
|
|
Loading…
Reference in a new issue