mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-25 19:16:19 +00:00
Compare commits
4 commits
b9d88156fc
...
b46b087bc6
Author | SHA1 | Date | |
---|---|---|---|
b46b087bc6 | |||
051b2524ab | |||
6cfe008b2b | |||
cdeb3c8d7d |
4 changed files with 48 additions and 24 deletions
BIN
sepa/bun.lockb
BIN
sepa/bun.lockb
Binary file not shown.
|
@ -196,10 +196,7 @@ export const sucursalesRelations = relations(sucursales, ({ one }) => ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// para actualizar la tabla:
|
// para actualizar la tabla:
|
||||||
// insert into productos_descripcion_index
|
// bun run scripts/refresh-descripciones-index.ts
|
||||||
// select distinct id_producto, productos_descripcion, productos_marca from precios
|
|
||||||
// on conflict do nothing;
|
|
||||||
// probablemente se pueda poner un where en el select para solo seleccionar precios recientes (tipo id_dataset > X)
|
|
||||||
export const productos_descripcion_index = pgTable(
|
export const productos_descripcion_index = pgTable(
|
||||||
"productos_descripcion_index",
|
"productos_descripcion_index",
|
||||||
{
|
{
|
||||||
|
|
27
sepa/scripts/refresh-descripciones-index.ts
Normal file
27
sepa/scripts/refresh-descripciones-index.ts
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import { drizzle } from "drizzle-orm/postgres-js";
|
||||||
|
import postgres from "postgres";
|
||||||
|
import * as schema from "../db/schema";
|
||||||
|
import { formatISO, subDays } from "date-fns";
|
||||||
|
import { sql } from "drizzle-orm";
|
||||||
|
|
||||||
|
const db = drizzle(postgres(), {
|
||||||
|
schema,
|
||||||
|
logger: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const aWeekAgo = subDays(new Date(), 5);
|
||||||
|
|
||||||
|
await db.execute(sql`
|
||||||
|
insert into productos_descripcion_index
|
||||||
|
select distinct id_producto, productos_descripcion, productos_marca from precios
|
||||||
|
where id_dataset in (
|
||||||
|
SELECT d1.id FROM datasets d1
|
||||||
|
JOIN (
|
||||||
|
SELECT id_comercio, MAX(date) as max_date
|
||||||
|
FROM datasets
|
||||||
|
WHERE date > ${formatISO(aWeekAgo, { representation: "date" })}
|
||||||
|
GROUP BY id_comercio
|
||||||
|
) d2 ON d1.id_comercio = d2.id_comercio AND d1.date = d2.max_date
|
||||||
|
ORDER BY d1.id_comercio)
|
||||||
|
on conflict do nothing;
|
||||||
|
`);
|
|
@ -15,37 +15,37 @@
|
||||||
"db:studio": "drizzle-kit studio"
|
"db:studio": "drizzle-kit studio"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/adapter-auto": "^3.0.0",
|
"@sveltejs/adapter-auto": "^3.2.5",
|
||||||
"@sveltejs/kit": "^2.0.0",
|
"@sveltejs/kit": "^2.5.28",
|
||||||
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.6",
|
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.7",
|
||||||
"@tailwindcss/typography": "^0.5.15",
|
"@tailwindcss/typography": "^0.5.15",
|
||||||
"@types/d3-scale": "^4.0.8",
|
"@types/d3-scale": "^4.0.8",
|
||||||
"@types/eslint": "^9.6.0",
|
"@types/eslint": "^9.6.1",
|
||||||
"@types/leaflet": "^1.9.12",
|
"@types/leaflet": "^1.9.12",
|
||||||
"@types/leaflet.markercluster": "^1.5.4",
|
"@types/leaflet.markercluster": "^1.5.4",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"drizzle-kit": "^0.24.2",
|
"drizzle-kit": "^0.24.2",
|
||||||
"eslint": "^9.0.0",
|
"eslint": "^9.11.1",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-svelte": "^2.36.0",
|
"eslint-plugin-svelte": "^2.44.0",
|
||||||
"globals": "^15.0.0",
|
"globals": "^15.9.0",
|
||||||
"prettier": "^3.3.2",
|
"prettier": "^3.3.3",
|
||||||
"prettier-plugin-svelte": "^3.2.5",
|
"prettier-plugin-svelte": "^3.2.6",
|
||||||
"prettier-plugin-tailwindcss": "^0.6.5",
|
"prettier-plugin-tailwindcss": "^0.6.6",
|
||||||
"svelte": "^5.0.0-next.1",
|
"svelte": "^5.0.0-next.258",
|
||||||
"svelte-adapter-bun": "^0.5.2",
|
"svelte-adapter-bun": "^0.5.2",
|
||||||
"svelte-check": "^3.6.0",
|
"svelte-check": "^3.8.6",
|
||||||
"tailwindcss": "^3.4.9",
|
"tailwindcss": "^3.4.13",
|
||||||
"typescript": "^5.0.0",
|
"typescript": "^5.6.2",
|
||||||
"typescript-eslint": "^8.0.0",
|
"typescript-eslint": "^8.7.0",
|
||||||
"vite": "^5.0.3"
|
"vite": "^5.4.7"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@maplibre/maplibre-gl-leaflet": "^0.0.22",
|
"@maplibre/maplibre-gl-leaflet": "^0.0.22",
|
||||||
"@sentry/sveltekit": "^8.30.0",
|
"@sentry/sveltekit": "^8.31.0",
|
||||||
"@types/node": "^22.5.0",
|
"@types/node": "^22.6.1",
|
||||||
"bits-ui": "^0.21.13",
|
"bits-ui": "^0.21.15",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"d3-array": "^3.2.4",
|
"d3-array": "^3.2.4",
|
||||||
"d3-scale": "^4.0.2",
|
"d3-scale": "^4.0.2",
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
"leaflet": "^1.9.4",
|
"leaflet": "^1.9.4",
|
||||||
"leaflet.markercluster": "^1.5.3",
|
"leaflet.markercluster": "^1.5.3",
|
||||||
"lucide-svelte": "^0.441.0",
|
"lucide-svelte": "^0.441.0",
|
||||||
"maplibre-gl": "^4.7.0",
|
"maplibre-gl": "^4.7.1",
|
||||||
"postgres": "^3.4.4",
|
"postgres": "^3.4.4",
|
||||||
"tailwind-merge": "^2.5.2",
|
"tailwind-merge": "^2.5.2",
|
||||||
"tailwind-variants": "^0.2.1"
|
"tailwind-variants": "^0.2.1"
|
||||||
|
|
Loading…
Reference in a new issue