Compare commits

..

No commits in common. "b46b087bc67e2cb4274cfffb71d6a6bae8d81f54" and "b9d88156fcc01d5b104af0daf1f3a76ec3c8c5ac" have entirely different histories.

4 changed files with 24 additions and 48 deletions

Binary file not shown.

View file

@ -196,7 +196,10 @@ export const sucursalesRelations = relations(sucursales, ({ one }) => ({
})); }));
// para actualizar la tabla: // para actualizar la tabla:
// bun run scripts/refresh-descripciones-index.ts // insert into productos_descripcion_index
// 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",
{ {

View file

@ -1,27 +0,0 @@
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;
`);

View file

@ -15,37 +15,37 @@
"db:studio": "drizzle-kit studio" "db:studio": "drizzle-kit studio"
}, },
"devDependencies": { "devDependencies": {
"@sveltejs/adapter-auto": "^3.2.5", "@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.5.28", "@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.7", "@sveltejs/vite-plugin-svelte": "^4.0.0-next.6",
"@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.1", "@types/eslint": "^9.6.0",
"@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.11.1", "eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.44.0", "eslint-plugin-svelte": "^2.36.0",
"globals": "^15.9.0", "globals": "^15.0.0",
"prettier": "^3.3.3", "prettier": "^3.3.2",
"prettier-plugin-svelte": "^3.2.6", "prettier-plugin-svelte": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.6.6", "prettier-plugin-tailwindcss": "^0.6.5",
"svelte": "^5.0.0-next.258", "svelte": "^5.0.0-next.1",
"svelte-adapter-bun": "^0.5.2", "svelte-adapter-bun": "^0.5.2",
"svelte-check": "^3.8.6", "svelte-check": "^3.6.0",
"tailwindcss": "^3.4.13", "tailwindcss": "^3.4.9",
"typescript": "^5.6.2", "typescript": "^5.0.0",
"typescript-eslint": "^8.7.0", "typescript-eslint": "^8.0.0",
"vite": "^5.4.7" "vite": "^5.0.3"
}, },
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@maplibre/maplibre-gl-leaflet": "^0.0.22", "@maplibre/maplibre-gl-leaflet": "^0.0.22",
"@sentry/sveltekit": "^8.31.0", "@sentry/sveltekit": "^8.30.0",
"@types/node": "^22.6.1", "@types/node": "^22.5.0",
"bits-ui": "^0.21.15", "bits-ui": "^0.21.13",
"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.1", "maplibre-gl": "^4.7.0",
"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"