Compare commits

..

17 commits

Author SHA1 Message Date
b05776a736 meta en index.html 2024-09-14 14:00:16 -03:00
bfc184cd69 fix nav en mobile 2024-09-14 13:55:52 -03:00
5ef31db0a4 intentar arreglar twitter card 2024-09-14 13:51:00 -03:00
28a22d0b0e arreglar boton de buscar 2024-09-14 13:48:41 -03:00
5e0e98bbcf ugh 2024-09-14 13:03:22 -03:00
5faedf6ebe deploy 2024-09-14 12:48:45 -03:00
42559cc6b6 favicon 2024-09-14 12:23:35 -03:00
287746c918 meta tags 2024-09-14 12:14:42 -03:00
2956e7eede umami 2024-09-14 12:08:57 -03:00
c11c7a6995 format 2024-09-14 12:07:05 -03:00
2ac54f25f6 enable sentry 2024-09-14 12:06:36 -03:00
84dda9b7e8 mostrar fecha del dataset 2024-09-14 11:51:30 -03:00
de64009e23 link a google maps 2024-09-14 11:50:11 -03:00
3c902dbc70 mejorar 2024-09-14 11:46:24 -03:00
2f6963e5f5 mejorar diseño 2024-09-14 11:09:13 -03:00
47f4f5fd48 shadcn svelte 2024-09-14 10:36:39 -03:00
51a3de40f9 sitio2 v0.0 2024-09-14 10:34:36 -03:00
63 changed files with 3421 additions and 69 deletions

15
sepa/.dockerignore Normal file
View file

@ -0,0 +1,15 @@
node_modules
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
Makefile
helm-charts
.env
.editorconfig
.idea
coverage*

58
sepa/Dockerfile Normal file
View file

@ -0,0 +1,58 @@
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1.1 as base
WORKDIR /usr/src/app
# install dependencies into temp directory
# this will cache them and speed up future builds
# FROM base AS install
# RUN mkdir -p /temp/dev
# COPY package.json bun.lockb /temp/dev/
# COPY sitio2/package.json /temp/dev/sitio2/
# RUN cd /temp/dev/sitio2 && bun install --frozen-lockfile
# # install with --production (exclude devDependencies)
# RUN mkdir -p /temp/prod
# COPY package.json bun.lockb /temp/prod/
# COPY sitio2/package.json /temp/prod/sitio2/
# RUN cd /temp/prod/sitio2 && bun install --frozen-lockfile --production
# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
# COPY --from=install /temp/dev/node_modules node_modules
COPY . .
COPY db/schema.ts sitio2/src/lib/server/db/schema.ts
RUN cd sitio2 && bun install --frozen-lockfile
ARG DATABASE_URL
# [optional] tests & build
ENV NODE_ENV=production
ENV DATABASE_URL=$DATABASE_URL
# RUN bun test
RUN cd sitio2 && env DATABASE_URL="postgres://user:password@host:5432/db-name" bun run build
# copy production dependencies and source code into final image
FROM base AS release
# COPY --from=prerelease /usr/src/app/node_modules node_modules
COPY --from=prerelease /usr/src/app/sitio2/build .
# COPY sitio2/build .
RUN bun install --frozen-lockfile
ARG DATABASE_URL
ARG PORT=3000
ENV DATABASE_URL=$DATABASE_URL
ENV PROTOCOL_HEADER=x-forwarded-proto
ENV HOST_HEADER=x-forwarded-host
ENV PORT=$PORT
# run the app
USER bun
EXPOSE $PORT/tcp
ENTRYPOINT [ "bun", "--bun", "run", "index.js" ]

Binary file not shown.

183
sepa/db/schema.ts Normal file
View file

@ -0,0 +1,183 @@
import { max, relations } from "drizzle-orm";
import {
pgTable,
integer,
bigint,
text,
numeric,
unique,
serial,
date,
index,
pgMaterializedView,
pgView,
} from "drizzle-orm/pg-core";
export const datasets = pgTable(
"datasets",
{
id: serial("id").primaryKey().notNull(),
name: text("name"),
date: date("date"),
id_comercio: integer("id_comercio"),
},
(table) => {
return {
datasets_name_key: unique("datasets_name_key").on(table.name),
};
}
);
export const precios = pgTable(
"precios",
{
id_dataset: integer("id_dataset").references(() => datasets.id),
id_comercio: integer("id_comercio"),
id_bandera: integer("id_bandera"),
id_sucursal: integer("id_sucursal"),
// You can use { mode: "bigint" } if numbers are exceeding js number limitations
id_producto: bigint("id_producto", { mode: "bigint" }),
productos_ean: integer("productos_ean"),
productos_descripcion: text("productos_descripcion"),
productos_cantidad_presentacion: numeric(
"productos_cantidad_presentacion",
{
precision: 10,
scale: 2,
}
),
productos_unidad_medida_presentacion: text(
"productos_unidad_medida_presentacion"
),
productos_marca: text("productos_marca"),
productos_precio_lista: numeric("productos_precio_lista", {
precision: 10,
scale: 2,
}),
productos_precio_referencia: numeric("productos_precio_referencia", {
precision: 10,
scale: 2,
}),
productos_cantidad_referencia: numeric("productos_cantidad_referencia", {
precision: 10,
scale: 2,
}),
productos_unidad_medida_referencia: text(
"productos_unidad_medida_referencia"
),
productos_precio_unitario_promo1: numeric(
"productos_precio_unitario_promo1",
{
precision: 10,
scale: 2,
}
),
productos_leyenda_promo1: text("productos_leyenda_promo1"),
productos_precio_unitario_promo2: numeric(
"productos_precio_unitario_promo2",
{
precision: 10,
scale: 2,
}
),
productos_leyenda_promo2: text("productos_leyenda_promo2"),
},
(table) => {
return {
idx_precios_id_producto: index("idx_precios_id_producto").using(
"btree",
table.id_producto
),
idx_precios_id_producto_id_dataset: index(
"idx_precios_id_producto_id_dataset"
).using("btree", table.id_producto, table.id_dataset),
};
}
);
export const sucursales = pgTable(
"sucursales",
{
id_dataset: integer("id_dataset").references(() => datasets.id),
id_comercio: integer("id_comercio"),
id_bandera: integer("id_bandera"),
id_sucursal: integer("id_sucursal"),
sucursales_nombre: text("sucursales_nombre"),
sucursales_tipo: text("sucursales_tipo"),
sucursales_calle: text("sucursales_calle"),
sucursales_numero: text("sucursales_numero"),
sucursales_latitud: numeric("sucursales_latitud"),
sucursales_longitud: numeric("sucursales_longitud"),
sucursales_observaciones: text("sucursales_observaciones"),
sucursales_barrio: text("sucursales_barrio"),
sucursales_codigo_postal: text("sucursales_codigo_postal"),
sucursales_localidad: text("sucursales_localidad"),
sucursales_provincia: text("sucursales_provincia"),
sucursales_lunes_horario_atencion: text(
"sucursales_lunes_horario_atencion"
),
sucursales_martes_horario_atencion: text(
"sucursales_martes_horario_atencion"
),
sucursales_miercoles_horario_atencion: text(
"sucursales_miercoles_horario_atencion"
),
sucursales_jueves_horario_atencion: text(
"sucursales_jueves_horario_atencion"
),
sucursales_viernes_horario_atencion: text(
"sucursales_viernes_horario_atencion"
),
sucursales_sabado_horario_atencion: text(
"sucursales_sabado_horario_atencion"
),
sucursales_domingo_horario_atencion: text(
"sucursales_domingo_horario_atencion"
),
},
(table) => {
return {
sucursales_id_dataset_id_comercio_id_bandera_id_sucursal_key: unique(
"sucursales_id_dataset_id_comercio_id_bandera_id_sucursal_key"
).on(
table.id_dataset,
table.id_comercio,
table.id_bandera,
table.id_sucursal
),
};
}
);
export const preciosRelations = relations(precios, ({ one }) => ({
dataset: one(datasets, {
fields: [precios.id_dataset],
references: [datasets.id],
}),
}));
export const datasetsRelations = relations(datasets, ({ many }) => ({
precios: many(precios),
sucursales: many(sucursales),
}));
export const sucursalesRelations = relations(sucursales, ({ one }) => ({
dataset: one(datasets, {
fields: [sucursales.id_dataset],
references: [datasets.id],
}),
}));
// para actualizar la tabla:
// 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(
"productos_descripcion_index",
{
id_producto: bigint("id_producto", { mode: "bigint" }),
productos_descripcion: text("productos_descripcion").unique(),
productos_marca: text("productos_marca"),
}
);

9
sepa/drizzle.config.ts Normal file
View file

@ -0,0 +1,9 @@
import { defineConfig } from "drizzle-kit";
export default defineConfig({
dialect: "postgresql",
schema: "./db/schema.ts",
out: "./drizzle",
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});

View file

@ -0,0 +1,73 @@
CREATE TABLE IF NOT EXISTS "datasets" (
"id" serial PRIMARY KEY NOT NULL,
"name" text,
"date" date,
CONSTRAINT "datasets_name_key" UNIQUE("name")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "precios" (
"id_dataset" integer,
"id_comercio" integer,
"id_bandera" integer,
"id_sucursal" integer,
"id_producto" bigint,
"productos_ean" integer,
"productos_descripcion" text,
"productos_cantidad_presentacion" numeric(10, 2),
"productos_unidad_medida_presentacion" text,
"productos_marca" text,
"productos_precio_lista" numeric(10, 2),
"productos_precio_referencia" numeric(10, 2),
"productos_cantidad_referencia" numeric(10, 2),
"productos_unidad_medida_referencia" text,
"productos_precio_unitario_promo1" numeric(10, 2),
"productos_leyenda_promo1" text,
"productos_precio_unitario_promo2" numeric(10, 2),
"productos_leyenda_promo2" text
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "productos_descripcion_index" (
"id_producto" bigint,
"productos_descripcion" text,
"productos_marca" text
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "sucursales" (
"id_dataset" integer,
"id_comercio" integer,
"id_bandera" integer,
"id_sucursal" integer,
"sucursales_nombre" text,
"sucursales_tipo" text,
"sucursales_calle" text,
"sucursales_numero" text,
"sucursales_latitud" numeric,
"sucursales_longitud" numeric,
"sucursales_observaciones" text,
"sucursales_barrio" text,
"sucursales_codigo_postal" text,
"sucursales_localidad" text,
"sucursales_provincia" text,
"sucursales_lunes_horario_atencion" text,
"sucursales_martes_horario_atencion" text,
"sucursales_miercoles_horario_atencion" text,
"sucursales_jueves_horario_atencion" text,
"sucursales_viernes_horario_atencion" text,
"sucursales_sabado_horario_atencion" text,
"sucursales_domingo_horario_atencion" text,
CONSTRAINT "sucursales_id_dataset_id_comercio_id_bandera_id_sucursal_key" UNIQUE("id_dataset","id_comercio","id_bandera","id_sucursal")
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "precios" ADD CONSTRAINT "precios_id_dataset_datasets_id_fk" FOREIGN KEY ("id_dataset") REFERENCES "public"."datasets"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "sucursales" ADD CONSTRAINT "sucursales_id_dataset_datasets_id_fk" FOREIGN KEY ("id_dataset") REFERENCES "public"."datasets"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "idx_precios_id_producto" ON "precios" USING btree ("id_producto");

View file

@ -0,0 +1 @@
ALTER TABLE "productos_descripcion_index" ADD CONSTRAINT "productos_descripcion_index_productos_descripcion_unique" UNIQUE("productos_descripcion");

View file

@ -0,0 +1,5 @@
ALTER TABLE "datasets" ADD COLUMN "id_comercio" integer;
--> statement-breakpoint
UPDATE "datasets"
SET "id_comercio" = CAST(SUBSTRING("name" FROM 'comercio-sepa-(\d+)') AS integer)
WHERE "name" ~ 'comercio-sepa-\d+';

View file

@ -0,0 +1 @@
CREATE INDEX IF NOT EXISTS "idx_precios_id_producto_id_dataset" ON "precios" USING btree ("id_producto","id_dataset");

View file

@ -0,0 +1,395 @@
{
"id": "9fc9be78-6665-4cd1-a5f6-d2998c71394a",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.datasets": {
"name": "datasets",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": false
},
"date": {
"name": "date",
"type": "date",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"datasets_name_key": {
"name": "datasets_name_key",
"nullsNotDistinct": false,
"columns": [
"name"
]
}
}
},
"public.precios": {
"name": "precios",
"schema": "",
"columns": {
"id_dataset": {
"name": "id_dataset",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_comercio": {
"name": "id_comercio",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_bandera": {
"name": "id_bandera",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_sucursal": {
"name": "id_sucursal",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_producto": {
"name": "id_producto",
"type": "bigint",
"primaryKey": false,
"notNull": false
},
"productos_ean": {
"name": "productos_ean",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"productos_descripcion": {
"name": "productos_descripcion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_cantidad_presentacion": {
"name": "productos_cantidad_presentacion",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_unidad_medida_presentacion": {
"name": "productos_unidad_medida_presentacion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_marca": {
"name": "productos_marca",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_precio_lista": {
"name": "productos_precio_lista",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_precio_referencia": {
"name": "productos_precio_referencia",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_cantidad_referencia": {
"name": "productos_cantidad_referencia",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_unidad_medida_referencia": {
"name": "productos_unidad_medida_referencia",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_precio_unitario_promo1": {
"name": "productos_precio_unitario_promo1",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_leyenda_promo1": {
"name": "productos_leyenda_promo1",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_precio_unitario_promo2": {
"name": "productos_precio_unitario_promo2",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_leyenda_promo2": {
"name": "productos_leyenda_promo2",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"idx_precios_id_producto": {
"name": "idx_precios_id_producto",
"columns": [
{
"expression": "id_producto",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"precios_id_dataset_datasets_id_fk": {
"name": "precios_id_dataset_datasets_id_fk",
"tableFrom": "precios",
"tableTo": "datasets",
"columnsFrom": [
"id_dataset"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.productos_descripcion_index": {
"name": "productos_descripcion_index",
"schema": "",
"columns": {
"id_producto": {
"name": "id_producto",
"type": "bigint",
"primaryKey": false,
"notNull": false
},
"productos_descripcion": {
"name": "productos_descripcion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_marca": {
"name": "productos_marca",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.sucursales": {
"name": "sucursales",
"schema": "",
"columns": {
"id_dataset": {
"name": "id_dataset",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_comercio": {
"name": "id_comercio",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_bandera": {
"name": "id_bandera",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_sucursal": {
"name": "id_sucursal",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"sucursales_nombre": {
"name": "sucursales_nombre",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_tipo": {
"name": "sucursales_tipo",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_calle": {
"name": "sucursales_calle",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_numero": {
"name": "sucursales_numero",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_latitud": {
"name": "sucursales_latitud",
"type": "numeric",
"primaryKey": false,
"notNull": false
},
"sucursales_longitud": {
"name": "sucursales_longitud",
"type": "numeric",
"primaryKey": false,
"notNull": false
},
"sucursales_observaciones": {
"name": "sucursales_observaciones",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_barrio": {
"name": "sucursales_barrio",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_codigo_postal": {
"name": "sucursales_codigo_postal",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_localidad": {
"name": "sucursales_localidad",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_provincia": {
"name": "sucursales_provincia",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_lunes_horario_atencion": {
"name": "sucursales_lunes_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_martes_horario_atencion": {
"name": "sucursales_martes_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_miercoles_horario_atencion": {
"name": "sucursales_miercoles_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_jueves_horario_atencion": {
"name": "sucursales_jueves_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_viernes_horario_atencion": {
"name": "sucursales_viernes_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_sabado_horario_atencion": {
"name": "sucursales_sabado_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_domingo_horario_atencion": {
"name": "sucursales_domingo_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"sucursales_id_dataset_datasets_id_fk": {
"name": "sucursales_id_dataset_datasets_id_fk",
"tableFrom": "sucursales",
"tableTo": "datasets",
"columnsFrom": [
"id_dataset"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"sucursales_id_dataset_id_comercio_id_bandera_id_sucursal_key": {
"name": "sucursales_id_dataset_id_comercio_id_bandera_id_sucursal_key",
"nullsNotDistinct": false,
"columns": [
"id_dataset",
"id_comercio",
"id_bandera",
"id_sucursal"
]
}
}
}
},
"enums": {},
"schemas": {},
"sequences": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View file

@ -0,0 +1,403 @@
{
"id": "c3ba3fea-1b63-40ef-9ea5-901d354ea6e2",
"prevId": "9fc9be78-6665-4cd1-a5f6-d2998c71394a",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.datasets": {
"name": "datasets",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": false
},
"date": {
"name": "date",
"type": "date",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"datasets_name_key": {
"name": "datasets_name_key",
"nullsNotDistinct": false,
"columns": [
"name"
]
}
}
},
"public.precios": {
"name": "precios",
"schema": "",
"columns": {
"id_dataset": {
"name": "id_dataset",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_comercio": {
"name": "id_comercio",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_bandera": {
"name": "id_bandera",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_sucursal": {
"name": "id_sucursal",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_producto": {
"name": "id_producto",
"type": "bigint",
"primaryKey": false,
"notNull": false
},
"productos_ean": {
"name": "productos_ean",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"productos_descripcion": {
"name": "productos_descripcion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_cantidad_presentacion": {
"name": "productos_cantidad_presentacion",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_unidad_medida_presentacion": {
"name": "productos_unidad_medida_presentacion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_marca": {
"name": "productos_marca",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_precio_lista": {
"name": "productos_precio_lista",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_precio_referencia": {
"name": "productos_precio_referencia",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_cantidad_referencia": {
"name": "productos_cantidad_referencia",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_unidad_medida_referencia": {
"name": "productos_unidad_medida_referencia",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_precio_unitario_promo1": {
"name": "productos_precio_unitario_promo1",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_leyenda_promo1": {
"name": "productos_leyenda_promo1",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_precio_unitario_promo2": {
"name": "productos_precio_unitario_promo2",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_leyenda_promo2": {
"name": "productos_leyenda_promo2",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"idx_precios_id_producto": {
"name": "idx_precios_id_producto",
"columns": [
{
"expression": "id_producto",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"precios_id_dataset_datasets_id_fk": {
"name": "precios_id_dataset_datasets_id_fk",
"tableFrom": "precios",
"tableTo": "datasets",
"columnsFrom": [
"id_dataset"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.productos_descripcion_index": {
"name": "productos_descripcion_index",
"schema": "",
"columns": {
"id_producto": {
"name": "id_producto",
"type": "bigint",
"primaryKey": false,
"notNull": false
},
"productos_descripcion": {
"name": "productos_descripcion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_marca": {
"name": "productos_marca",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"productos_descripcion_index_productos_descripcion_unique": {
"name": "productos_descripcion_index_productos_descripcion_unique",
"nullsNotDistinct": false,
"columns": [
"productos_descripcion"
]
}
}
},
"public.sucursales": {
"name": "sucursales",
"schema": "",
"columns": {
"id_dataset": {
"name": "id_dataset",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_comercio": {
"name": "id_comercio",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_bandera": {
"name": "id_bandera",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_sucursal": {
"name": "id_sucursal",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"sucursales_nombre": {
"name": "sucursales_nombre",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_tipo": {
"name": "sucursales_tipo",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_calle": {
"name": "sucursales_calle",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_numero": {
"name": "sucursales_numero",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_latitud": {
"name": "sucursales_latitud",
"type": "numeric",
"primaryKey": false,
"notNull": false
},
"sucursales_longitud": {
"name": "sucursales_longitud",
"type": "numeric",
"primaryKey": false,
"notNull": false
},
"sucursales_observaciones": {
"name": "sucursales_observaciones",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_barrio": {
"name": "sucursales_barrio",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_codigo_postal": {
"name": "sucursales_codigo_postal",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_localidad": {
"name": "sucursales_localidad",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_provincia": {
"name": "sucursales_provincia",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_lunes_horario_atencion": {
"name": "sucursales_lunes_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_martes_horario_atencion": {
"name": "sucursales_martes_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_miercoles_horario_atencion": {
"name": "sucursales_miercoles_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_jueves_horario_atencion": {
"name": "sucursales_jueves_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_viernes_horario_atencion": {
"name": "sucursales_viernes_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_sabado_horario_atencion": {
"name": "sucursales_sabado_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_domingo_horario_atencion": {
"name": "sucursales_domingo_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"sucursales_id_dataset_datasets_id_fk": {
"name": "sucursales_id_dataset_datasets_id_fk",
"tableFrom": "sucursales",
"tableTo": "datasets",
"columnsFrom": [
"id_dataset"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"sucursales_id_dataset_id_comercio_id_bandera_id_sucursal_key": {
"name": "sucursales_id_dataset_id_comercio_id_bandera_id_sucursal_key",
"nullsNotDistinct": false,
"columns": [
"id_dataset",
"id_comercio",
"id_bandera",
"id_sucursal"
]
}
}
}
},
"enums": {},
"schemas": {},
"sequences": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View file

@ -0,0 +1,409 @@
{
"id": "4021f198-46b8-4699-a32c-4fbc30fe87d0",
"prevId": "c3ba3fea-1b63-40ef-9ea5-901d354ea6e2",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.datasets": {
"name": "datasets",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": false
},
"date": {
"name": "date",
"type": "date",
"primaryKey": false,
"notNull": false
},
"id_comercio": {
"name": "id_comercio",
"type": "integer",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"datasets_name_key": {
"name": "datasets_name_key",
"nullsNotDistinct": false,
"columns": [
"name"
]
}
}
},
"public.precios": {
"name": "precios",
"schema": "",
"columns": {
"id_dataset": {
"name": "id_dataset",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_comercio": {
"name": "id_comercio",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_bandera": {
"name": "id_bandera",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_sucursal": {
"name": "id_sucursal",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_producto": {
"name": "id_producto",
"type": "bigint",
"primaryKey": false,
"notNull": false
},
"productos_ean": {
"name": "productos_ean",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"productos_descripcion": {
"name": "productos_descripcion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_cantidad_presentacion": {
"name": "productos_cantidad_presentacion",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_unidad_medida_presentacion": {
"name": "productos_unidad_medida_presentacion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_marca": {
"name": "productos_marca",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_precio_lista": {
"name": "productos_precio_lista",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_precio_referencia": {
"name": "productos_precio_referencia",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_cantidad_referencia": {
"name": "productos_cantidad_referencia",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_unidad_medida_referencia": {
"name": "productos_unidad_medida_referencia",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_precio_unitario_promo1": {
"name": "productos_precio_unitario_promo1",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_leyenda_promo1": {
"name": "productos_leyenda_promo1",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_precio_unitario_promo2": {
"name": "productos_precio_unitario_promo2",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_leyenda_promo2": {
"name": "productos_leyenda_promo2",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"idx_precios_id_producto": {
"name": "idx_precios_id_producto",
"columns": [
{
"expression": "id_producto",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"precios_id_dataset_datasets_id_fk": {
"name": "precios_id_dataset_datasets_id_fk",
"tableFrom": "precios",
"tableTo": "datasets",
"columnsFrom": [
"id_dataset"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.productos_descripcion_index": {
"name": "productos_descripcion_index",
"schema": "",
"columns": {
"id_producto": {
"name": "id_producto",
"type": "bigint",
"primaryKey": false,
"notNull": false
},
"productos_descripcion": {
"name": "productos_descripcion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_marca": {
"name": "productos_marca",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"productos_descripcion_index_productos_descripcion_unique": {
"name": "productos_descripcion_index_productos_descripcion_unique",
"nullsNotDistinct": false,
"columns": [
"productos_descripcion"
]
}
}
},
"public.sucursales": {
"name": "sucursales",
"schema": "",
"columns": {
"id_dataset": {
"name": "id_dataset",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_comercio": {
"name": "id_comercio",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_bandera": {
"name": "id_bandera",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_sucursal": {
"name": "id_sucursal",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"sucursales_nombre": {
"name": "sucursales_nombre",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_tipo": {
"name": "sucursales_tipo",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_calle": {
"name": "sucursales_calle",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_numero": {
"name": "sucursales_numero",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_latitud": {
"name": "sucursales_latitud",
"type": "numeric",
"primaryKey": false,
"notNull": false
},
"sucursales_longitud": {
"name": "sucursales_longitud",
"type": "numeric",
"primaryKey": false,
"notNull": false
},
"sucursales_observaciones": {
"name": "sucursales_observaciones",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_barrio": {
"name": "sucursales_barrio",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_codigo_postal": {
"name": "sucursales_codigo_postal",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_localidad": {
"name": "sucursales_localidad",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_provincia": {
"name": "sucursales_provincia",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_lunes_horario_atencion": {
"name": "sucursales_lunes_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_martes_horario_atencion": {
"name": "sucursales_martes_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_miercoles_horario_atencion": {
"name": "sucursales_miercoles_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_jueves_horario_atencion": {
"name": "sucursales_jueves_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_viernes_horario_atencion": {
"name": "sucursales_viernes_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_sabado_horario_atencion": {
"name": "sucursales_sabado_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_domingo_horario_atencion": {
"name": "sucursales_domingo_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"sucursales_id_dataset_datasets_id_fk": {
"name": "sucursales_id_dataset_datasets_id_fk",
"tableFrom": "sucursales",
"tableTo": "datasets",
"columnsFrom": [
"id_dataset"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"sucursales_id_dataset_id_comercio_id_bandera_id_sucursal_key": {
"name": "sucursales_id_dataset_id_comercio_id_bandera_id_sucursal_key",
"nullsNotDistinct": false,
"columns": [
"id_dataset",
"id_comercio",
"id_bandera",
"id_sucursal"
]
}
}
}
},
"enums": {},
"schemas": {},
"sequences": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View file

@ -0,0 +1,430 @@
{
"id": "7ea9c123-4d12-4f0b-9452-e8952462fbf8",
"prevId": "4021f198-46b8-4699-a32c-4fbc30fe87d0",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.datasets": {
"name": "datasets",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": false
},
"date": {
"name": "date",
"type": "date",
"primaryKey": false,
"notNull": false
},
"id_comercio": {
"name": "id_comercio",
"type": "integer",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"datasets_name_key": {
"name": "datasets_name_key",
"nullsNotDistinct": false,
"columns": [
"name"
]
}
}
},
"public.precios": {
"name": "precios",
"schema": "",
"columns": {
"id_dataset": {
"name": "id_dataset",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_comercio": {
"name": "id_comercio",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_bandera": {
"name": "id_bandera",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_sucursal": {
"name": "id_sucursal",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_producto": {
"name": "id_producto",
"type": "bigint",
"primaryKey": false,
"notNull": false
},
"productos_ean": {
"name": "productos_ean",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"productos_descripcion": {
"name": "productos_descripcion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_cantidad_presentacion": {
"name": "productos_cantidad_presentacion",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_unidad_medida_presentacion": {
"name": "productos_unidad_medida_presentacion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_marca": {
"name": "productos_marca",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_precio_lista": {
"name": "productos_precio_lista",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_precio_referencia": {
"name": "productos_precio_referencia",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_cantidad_referencia": {
"name": "productos_cantidad_referencia",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_unidad_medida_referencia": {
"name": "productos_unidad_medida_referencia",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_precio_unitario_promo1": {
"name": "productos_precio_unitario_promo1",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_leyenda_promo1": {
"name": "productos_leyenda_promo1",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_precio_unitario_promo2": {
"name": "productos_precio_unitario_promo2",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"productos_leyenda_promo2": {
"name": "productos_leyenda_promo2",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"idx_precios_id_producto": {
"name": "idx_precios_id_producto",
"columns": [
{
"expression": "id_producto",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"idx_precios_id_producto_id_dataset": {
"name": "idx_precios_id_producto_id_dataset",
"columns": [
{
"expression": "id_producto",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "id_dataset",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"precios_id_dataset_datasets_id_fk": {
"name": "precios_id_dataset_datasets_id_fk",
"tableFrom": "precios",
"tableTo": "datasets",
"columnsFrom": [
"id_dataset"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.productos_descripcion_index": {
"name": "productos_descripcion_index",
"schema": "",
"columns": {
"id_producto": {
"name": "id_producto",
"type": "bigint",
"primaryKey": false,
"notNull": false
},
"productos_descripcion": {
"name": "productos_descripcion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"productos_marca": {
"name": "productos_marca",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"productos_descripcion_index_productos_descripcion_unique": {
"name": "productos_descripcion_index_productos_descripcion_unique",
"nullsNotDistinct": false,
"columns": [
"productos_descripcion"
]
}
}
},
"public.sucursales": {
"name": "sucursales",
"schema": "",
"columns": {
"id_dataset": {
"name": "id_dataset",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_comercio": {
"name": "id_comercio",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_bandera": {
"name": "id_bandera",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"id_sucursal": {
"name": "id_sucursal",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"sucursales_nombre": {
"name": "sucursales_nombre",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_tipo": {
"name": "sucursales_tipo",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_calle": {
"name": "sucursales_calle",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_numero": {
"name": "sucursales_numero",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_latitud": {
"name": "sucursales_latitud",
"type": "numeric",
"primaryKey": false,
"notNull": false
},
"sucursales_longitud": {
"name": "sucursales_longitud",
"type": "numeric",
"primaryKey": false,
"notNull": false
},
"sucursales_observaciones": {
"name": "sucursales_observaciones",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_barrio": {
"name": "sucursales_barrio",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_codigo_postal": {
"name": "sucursales_codigo_postal",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_localidad": {
"name": "sucursales_localidad",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_provincia": {
"name": "sucursales_provincia",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_lunes_horario_atencion": {
"name": "sucursales_lunes_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_martes_horario_atencion": {
"name": "sucursales_martes_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_miercoles_horario_atencion": {
"name": "sucursales_miercoles_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_jueves_horario_atencion": {
"name": "sucursales_jueves_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_viernes_horario_atencion": {
"name": "sucursales_viernes_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_sabado_horario_atencion": {
"name": "sucursales_sabado_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sucursales_domingo_horario_atencion": {
"name": "sucursales_domingo_horario_atencion",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"sucursales_id_dataset_datasets_id_fk": {
"name": "sucursales_id_dataset_datasets_id_fk",
"tableFrom": "sucursales",
"tableTo": "datasets",
"columnsFrom": [
"id_dataset"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"sucursales_id_dataset_id_comercio_id_bandera_id_sucursal_key": {
"name": "sucursales_id_dataset_id_comercio_id_bandera_id_sucursal_key",
"nullsNotDistinct": false,
"columns": [
"id_dataset",
"id_comercio",
"id_bandera",
"id_sucursal"
]
}
}
}
},
"enums": {},
"schemas": {},
"sequences": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View file

@ -0,0 +1,34 @@
{
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "7",
"when": 1726278563872,
"tag": "0000_round_darwin",
"breakpoints": true
},
{
"idx": 1,
"version": "7",
"when": 1726279968009,
"tag": "0001_abandoned_paladin",
"breakpoints": true
},
{
"idx": 2,
"version": "7",
"when": 1726281666522,
"tag": "0002_silly_thunderbird",
"breakpoints": true
},
{
"idx": 3,
"version": "7",
"when": 1726283266814,
"tag": "0003_strong_bucky",
"breakpoints": true
}
]
}

View file

@ -13,73 +13,6 @@ const sql = postgres({
database: "sepa-precios", database: "sepa-precios",
}); });
// await sql`
// drop table if exists precios;`;
// await sql`
// drop table if exists datasets;`;
await sql`
CREATE TABLE if not exists datasets (
id SERIAL PRIMARY KEY,
name TEXT UNIQUE,
date DATE
);`;
await sql`
CREATE TABLE if not exists sucursales (
id_dataset INTEGER REFERENCES datasets(id),
id_comercio INTEGER,
id_bandera INTEGER,
id_sucursal INTEGER,
sucursales_nombre TEXT,
sucursales_tipo TEXT,
sucursales_calle TEXT,
sucursales_numero TEXT,
sucursales_latitud NUMERIC,
sucursales_longitud NUMERIC,
sucursales_observaciones TEXT,
sucursales_barrio TEXT,
sucursales_codigo_postal TEXT,
sucursales_localidad TEXT,
sucursales_provincia TEXT,
sucursales_lunes_horario_atencion TEXT,
sucursales_martes_horario_atencion TEXT,
sucursales_miercoles_horario_atencion TEXT,
sucursales_jueves_horario_atencion TEXT,
sucursales_viernes_horario_atencion TEXT,
sucursales_sabado_horario_atencion TEXT,
sucursales_domingo_horario_atencion TEXT,
UNIQUE (id_dataset, id_comercio, id_bandera, id_sucursal)
);`;
await sql`
CREATE TABLE if not exists precios (
id_dataset INTEGER REFERENCES datasets(id),
id_comercio INTEGER,
id_bandera INTEGER,
id_sucursal INTEGER,
id_producto BIGINT,
productos_ean INTEGER,
productos_descripcion TEXT,
productos_cantidad_presentacion NUMERIC(10, 2),
productos_unidad_medida_presentacion TEXT,
productos_marca TEXT,
productos_precio_lista NUMERIC(10, 2),
productos_precio_referencia NUMERIC(10, 2),
productos_cantidad_referencia NUMERIC(10, 2),
productos_unidad_medida_referencia TEXT,
productos_precio_unitario_promo1 NUMERIC(10, 2),
productos_leyenda_promo1 TEXT,
productos_precio_unitario_promo2 NUMERIC(10, 2),
productos_leyenda_promo2 TEXT
);
`;
await sql`
CREATE INDEX IF NOT EXISTS idx_precios_composite ON precios (id_dataset, id_comercio, id_bandera, id_sucursal, id_producto);
`;
await sql`
CREATE INDEX IF NOT EXISTS idx_sucursales_composite ON sucursales (id_dataset, id_comercio, id_bandera, id_sucursal);
`;
async function readFile(path: string) { async function readFile(path: string) {
// XXX: DORINKA SRL a veces envía archivos con UTF-16. // XXX: DORINKA SRL a veces envía archivos con UTF-16.
const buffer = await fs.readFile(path, { encoding: null }); const buffer = await fs.readFile(path, { encoding: null });

View file

@ -4,7 +4,8 @@
"type": "module", "type": "module",
"devDependencies": { "devDependencies": {
"@types/bun": "^1.1.7", "@types/bun": "^1.1.7",
"@types/papaparse": "^5.3.14" "@types/papaparse": "^5.3.14",
"drizzle-kit": "^0.24.2"
}, },
"peerDependencies": { "peerDependencies": {
"typescript": "^5.0.0" "typescript": "^5.0.0"
@ -13,10 +14,14 @@
"@aws-sdk/client-s3": "^3.651.0", "@aws-sdk/client-s3": "^3.651.0",
"@aws-sdk/lib-storage": "^3.651.0", "@aws-sdk/lib-storage": "^3.651.0",
"date-fns": "^3.6.0", "date-fns": "^3.6.0",
"drizzle-orm": "^0.33.0",
"jschardet": "^3.1.3", "jschardet": "^3.1.3",
"p-queue": "^8.0.1", "p-queue": "^8.0.1",
"papaparse": "^5.4.1", "papaparse": "^5.4.1",
"postgres": "^3.4.4", "postgres": "^3.4.4",
"zod": "^3.23.8" "zod": "^3.23.8"
} },
"workspaces": [
"sitio2"
]
} }

2
sepa/sitio2/.env.example Normal file
View file

@ -0,0 +1,2 @@
# Replace with your DB credentials!
DATABASE_URL="postgres://user:password@host:5432/db-name"

24
sepa/sitio2/.gitignore vendored Normal file
View file

@ -0,0 +1,24 @@
node_modules
# Output
.output
.vercel
/.svelte-kit
/build
# OS
.DS_Store
Thumbs.db
# Env
.env
.env.*
!.env.example
!.env.test
# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
# Sentry Config File
.sentryclirc

1
sepa/sitio2/.npmrc Normal file
View file

@ -0,0 +1 @@
engine-strict=true

View file

@ -0,0 +1,4 @@
# Package Managers
package-lock.json
pnpm-lock.yaml
yarn.lock

15
sepa/sitio2/.prettierrc Normal file
View file

@ -0,0 +1,15 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte"
}
}
]
}

38
sepa/sitio2/README.md Normal file
View file

@ -0,0 +1,38 @@
# create-svelte
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
## Creating a project
If you're seeing this, you've probably already done this step. Congrats!
```bash
# create a new project in the current directory
npm create svelte@latest
# create a new project in my-app
npm create svelte@latest my-app
```
## Developing
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
```bash
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
```
## Building
To create a production version of your app:
```bash
npm run build
```
You can preview the production build with `npm run preview`.
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.

View file

@ -0,0 +1,14 @@
{
"$schema": "https://shadcn-svelte.com/schema.json",
"style": "default",
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/app.css",
"baseColor": "zinc"
},
"aliases": {
"components": "$lib/components",
"utils": "$lib/utils"
},
"typescript": true
}

View file

@ -0,0 +1,14 @@
import { defineConfig } from 'drizzle-kit';
if (!process.env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
export default defineConfig({
schema: './src/lib/server/db/schema.ts',
dbCredentials: {
url: process.env.DATABASE_URL
},
verbose: true,
strict: true,
dialect: 'postgresql'
});

View file

@ -0,0 +1,33 @@
import js from '@eslint/js';
import ts from 'typescript-eslint';
import svelte from 'eslint-plugin-svelte';
import prettier from 'eslint-config-prettier';
import globals from 'globals';
/** @type {import('eslint').Linter.Config[]} */
export default [
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs['flat/recommended'],
prettier,
...svelte.configs['flat/prettier'],
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
},
{
files: ['**/*.svelte'],
languageOptions: {
parserOptions: {
parser: ts.parser
}
}
},
{
ignores: ['build/', '.svelte-kit/', 'dist/']
}
];

56
sepa/sitio2/package.json Normal file
View file

@ -0,0 +1,56 @@
{
"name": "sitio2",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"db:push": "drizzle-kit push",
"db:migrate": "drizzle-kit migrate",
"db:studio": "drizzle-kit studio"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.6",
"@tailwindcss/typography": "^0.5.15",
"@types/eslint": "^9.6.0",
"@types/leaflet": "^1.9.12",
"@types/leaflet.markercluster": "^1.5.4",
"autoprefixer": "^10.4.20",
"drizzle-kit": "^0.24.2",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0",
"globals": "^15.0.0",
"prettier": "^3.3.2",
"prettier-plugin-svelte": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.6.5",
"svelte": "^5.0.0-next.1",
"svelte-adapter-bun": "^0.5.2",
"svelte-check": "^3.6.0",
"tailwindcss": "^3.4.9",
"typescript": "^5.0.0",
"typescript-eslint": "^8.0.0",
"vite": "^5.0.3"
},
"type": "module",
"dependencies": {
"@sentry/sveltekit": "^8.30.0",
"@types/node": "^22.5.0",
"bits-ui": "^0.21.13",
"clsx": "^2.1.1",
"drizzle-orm": "^0.33.0",
"leaflet": "^1.9.4",
"leaflet.markercluster": "^1.5.3",
"lucide-svelte": "^0.441.0",
"postgres": "^3.4.4",
"tailwind-merge": "^2.5.2",
"tailwind-variants": "^0.2.1"
}
}

View file

@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
};

86
sepa/sitio2/src/app.css Normal file
View file

@ -0,0 +1,86 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--background: 0 0% 100%;
--foreground: 240 10% 3.9%;
--muted: 240 4.8% 95.9%;
--muted-foreground: 240 3.8% 46.1%;
--popover: 0 0% 100%;
--popover-foreground: 240 10% 3.9%;
--card: 0 0% 100%;
--card-foreground: 240 10% 3.9%;
--border: 240 5.9% 90%;
--input: 240 5.9% 90%;
--primary: 240 5.9% 10%;
--primary-foreground: 0 0% 98%;
--secondary: 240 4.8% 95.9%;
--secondary-foreground: 240 5.9% 10%;
--accent: 240 4.8% 95.9%;
--accent-foreground: 240 5.9% 10%;
--destructive: 0 72.2% 50.6%;
--destructive-foreground: 0 0% 98%;
--ring: 240 10% 3.9%;
--radius: 0.5rem;
}
.dark {
--background: 240 10% 3.9%;
--foreground: 0 0% 98%;
--muted: 240 3.7% 15.9%;
--muted-foreground: 240 5% 64.9%;
--popover: 240 10% 3.9%;
--popover-foreground: 0 0% 98%;
--card: 240 10% 3.9%;
--card-foreground: 0 0% 98%;
--border: 240 3.7% 15.9%;
--input: 240 3.7% 15.9%;
--primary: 0 0% 98%;
--primary-foreground: 240 5.9% 10%;
--secondary: 240 3.7% 15.9%;
--secondary-foreground: 0 0% 98%;
--accent: 240 3.7% 15.9%;
--accent-foreground: 0 0% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 0 0% 98%;
--ring: 240 4.9% 83.9%;
}
}
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
html,
body,
body > div {
min-height: 100vh;
margin: 0;
padding: 0;
}

13
sepa/sitio2/src/app.d.ts vendored Normal file
View file

@ -0,0 +1,13 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}
}
}
export {};

33
sepa/sitio2/src/app.html Normal file
View file

@ -0,0 +1,33 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Preciazo</title>
<meta name="description" content="Busca precios de productos en distintas cadenas de supermercados en Argentina." />
<meta content="index, follow" name="robots" />
<meta property="og:title" content="Preciazo" />
<meta property="og:description"
content="Busca precios de productos en distintas cadenas de supermercados en Argentina." />
<meta property="og:image" content="https://preciazo.nulo.in/favicon.png" />
<meta property="og:url" content={`https://preciazo.nulo.in${data.pathname}`} />
<meta property="og:type" content="website" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@esoesnulo" />
<meta name="twitter:title" content="Preciazo" />
<meta name="twitter:description"
content="Busca precios de productos en distintas cadenas de supermercados en Argentina." />
<meta name="twitter:image" content="https://preciazo.nulo.in/favicon.png" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>

View file

@ -0,0 +1,12 @@
import { handleErrorWithSentry } from '@sentry/sveltekit';
import * as Sentry from '@sentry/sveltekit';
if (import.meta.env.PROD) {
Sentry.init({
dsn: 'https://1177c12a82e0a16aeb1b637bcf392f20@o4507188153548800.ingest.de.sentry.io/4507951835447376',
tracesSampleRate: 1.0
});
}
// If you have a custom error handler, pass it to `handleErrorWithSentry`
export const handleError = handleErrorWithSentry();

View file

@ -0,0 +1,20 @@
import { sequence } from '@sveltejs/kit/hooks';
import { handleErrorWithSentry, sentryHandle } from '@sentry/sveltekit';
import * as Sentry from '@sentry/sveltekit';
if (import.meta.env.PROD) {
Sentry.init({
dsn: 'https://1177c12a82e0a16aeb1b637bcf392f20@o4507188153548800.ingest.de.sentry.io/4507951835447376',
tracesSampleRate: 1.0
// uncomment the line below to enable Spotlight (https://spotlightjs.com)
// spotlight: import.meta.env.DEV,
});
}
// If you have custom handlers, make sure to place them after `sentryHandle()` in the `sequence` function.
export const handle = sequence(sentryHandle());
// If you have a custom error handler, pass it to `handleErrorWithSentry`
export const handleError = handleErrorWithSentry();

View file

@ -0,0 +1,55 @@
<script lang="ts">
import { onDestroy, onMount, tick } from 'svelte';
import 'leaflet/dist/leaflet.css';
import type L from 'leaflet';
let mapEl: HTMLDivElement;
export let mapMap: (map: L.Map, l: typeof L) => void;
let map: L.Map | undefined;
onMount(async () => {
const L = await import('leaflet');
// Set up initial map center and zoom level
map = L.map(mapEl, {
center: [-34.599722222222, -58.381944444444], // EDIT latitude, longitude to re-center map
zoom: 9, // EDIT from 1 to 18 -- decrease to zoom out, increase to zoom in
scrollWheelZoom: true // Changed to true to enable zoom with scrollwheel
// tap: false
});
/* Control panel to display map layers */
// var controlLayers = L.control.layers( null, null, {
// position: "topright",
// collapsed: false
// }).addTo(map);
// display Carto basemap tiles with light features and labels
L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png', {
attribution:
'&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, &copy; <a href="https://carto.com/attribution">CARTO</a>'
}).addTo(map);
mapMap(map, L);
});
onDestroy(() => {
map?.remove();
map = undefined;
});
</script>
<div class="wrapper flex-auto">
<div class="map" bind:this={mapEl}></div>
</div>
<style>
.map {
width: 100%;
height: 100%;
position: absolute !important;
}
.wrapper {
position: relative;
width: 100%;
height: 100%;
}
</style>

View file

@ -0,0 +1,17 @@
<script lang="ts">
import { Input } from '$lib/components/ui/input';
import { Button } from '$lib/components/ui/button';
import { goto } from '$app/navigation';
import { page } from '$app/stores';
let search = $page.params.query ?? '';
function handleSubmit() {
goto(`/search/${encodeURIComponent(search)}`);
}
</script>
<form class="flex gap-2" on:submit|preventDefault={handleSubmit}>
<Input placeholder="Buscar productos" bind:value={search} />
<Button type="submit">Buscar</Button>
</form>

View file

@ -0,0 +1,18 @@
<script lang="ts">
import { type Variant, badgeVariants } from './index.js';
import { cn } from '$lib/utils.js';
let className: string | undefined | null = undefined;
export let href: string | undefined = undefined;
export let variant: Variant = 'default';
export { className as class };
</script>
<svelte:element
this={href ? 'a' : 'span'}
{href}
class={cn(badgeVariants({ variant, className }))}
{...$$restProps}
>
<slot />
</svelte:element>

View file

@ -0,0 +1,20 @@
import { type VariantProps, tv } from 'tailwind-variants';
export { default as Badge } from './badge.svelte';
export const badgeVariants = tv({
base: 'focus:ring-ring inline-flex select-none items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2',
variants: {
variant: {
default: 'bg-primary text-primary-foreground hover:bg-primary/80 border-transparent',
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80 border-transparent',
destructive:
'bg-destructive text-destructive-foreground hover:bg-destructive/80 border-transparent',
outline: 'text-foreground'
}
},
defaultVariants: {
variant: 'default'
}
});
export type Variant = VariantProps<typeof badgeVariants>['variant'];

View file

@ -0,0 +1,25 @@
<script lang="ts">
import { Button as ButtonPrimitive } from 'bits-ui';
import { type Events, type Props, buttonVariants } from './index.js';
import { cn } from '$lib/utils.js';
type $$Props = Props;
type $$Events = Events;
let className: $$Props['class'] = undefined;
export let variant: $$Props['variant'] = 'default';
export let size: $$Props['size'] = 'default';
export let builders: $$Props['builders'] = [];
export { className as class };
</script>
<ButtonPrimitive.Root
{builders}
class={cn(buttonVariants({ variant, size, className }))}
type="button"
{...$$restProps}
on:click
on:keydown
>
<slot />
</ButtonPrimitive.Root>

View file

@ -0,0 +1,48 @@
import { type VariantProps, tv } from 'tailwind-variants';
import type { Button as ButtonPrimitive } from 'bits-ui';
import Root from './button.svelte';
const buttonVariants = tv({
base: 'ring-offset-background focus-visible:ring-ring inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
variants: {
variant: {
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
outline: 'border-input bg-background hover:bg-accent hover:text-accent-foreground border',
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline'
},
size: {
default: 'h-10 px-4 py-2',
sm: 'h-9 rounded-md px-3',
lg: 'h-11 rounded-md px-8',
icon: 'h-10 w-10'
}
},
defaultVariants: {
variant: 'default',
size: 'default'
}
});
type Variant = VariantProps<typeof buttonVariants>['variant'];
type Size = VariantProps<typeof buttonVariants>['size'];
type Props = ButtonPrimitive.Props & {
variant?: Variant;
size?: Size;
};
type Events = ButtonPrimitive.Events;
export {
Root,
type Props,
type Events,
//
Root as Button,
type Props as ButtonProps,
type Events as ButtonEvents,
buttonVariants
};

View file

@ -0,0 +1,13 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import { cn } from '$lib/utils.js';
type $$Props = HTMLAttributes<HTMLDivElement>;
let className: $$Props['class'] = undefined;
export { className as class };
</script>
<div class={cn('p-6 pt-0', className)} {...$$restProps}>
<slot />
</div>

View file

@ -0,0 +1,13 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import { cn } from '$lib/utils.js';
type $$Props = HTMLAttributes<HTMLParagraphElement>;
let className: $$Props['class'] = undefined;
export { className as class };
</script>
<p class={cn('text-sm text-muted-foreground', className)} {...$$restProps}>
<slot />
</p>

View file

@ -0,0 +1,13 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import { cn } from '$lib/utils.js';
type $$Props = HTMLAttributes<HTMLDivElement>;
let className: $$Props['class'] = undefined;
export { className as class };
</script>
<div class={cn('flex items-center p-6 pt-0', className)} {...$$restProps}>
<slot />
</div>

View file

@ -0,0 +1,13 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import { cn } from '$lib/utils.js';
type $$Props = HTMLAttributes<HTMLDivElement>;
let className: $$Props['class'] = undefined;
export { className as class };
</script>
<div class={cn('flex flex-col space-y-1.5 p-6', className)} {...$$restProps}>
<slot />
</div>

View file

@ -0,0 +1,21 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import type { HeadingLevel } from './index.js';
import { cn } from '$lib/utils.js';
type $$Props = HTMLAttributes<HTMLHeadingElement> & {
tag?: HeadingLevel;
};
let className: $$Props['class'] = undefined;
export let tag: $$Props['tag'] = 'h3';
export { className as class };
</script>
<svelte:element
this={tag}
class={cn('text-lg font-semibold leading-none tracking-tight', className)}
{...$$restProps}
>
<slot />
</svelte:element>

View file

@ -0,0 +1,16 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import { cn } from '$lib/utils.js';
type $$Props = HTMLAttributes<HTMLDivElement>;
let className: $$Props['class'] = undefined;
export { className as class };
</script>
<div
class={cn('rounded-lg border bg-card text-card-foreground shadow-sm', className)}
{...$$restProps}
>
<slot />
</div>

View file

@ -0,0 +1,24 @@
import Root from './card.svelte';
import Content from './card-content.svelte';
import Description from './card-description.svelte';
import Footer from './card-footer.svelte';
import Header from './card-header.svelte';
import Title from './card-title.svelte';
export {
Root,
Content,
Description,
Footer,
Header,
Title,
//
Root as Card,
Content as CardContent,
Description as CardDescription,
Footer as CardFooter,
Header as CardHeader,
Title as CardTitle
};
export type HeadingLevel = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';

View file

@ -0,0 +1,29 @@
import Root from './input.svelte';
export type FormInputEvent<T extends Event = Event> = T & {
currentTarget: EventTarget & HTMLInputElement;
};
export type InputEvents = {
blur: FormInputEvent<FocusEvent>;
change: FormInputEvent<Event>;
click: FormInputEvent<MouseEvent>;
focus: FormInputEvent<FocusEvent>;
focusin: FormInputEvent<FocusEvent>;
focusout: FormInputEvent<FocusEvent>;
keydown: FormInputEvent<KeyboardEvent>;
keypress: FormInputEvent<KeyboardEvent>;
keyup: FormInputEvent<KeyboardEvent>;
mouseover: FormInputEvent<MouseEvent>;
mouseenter: FormInputEvent<MouseEvent>;
mouseleave: FormInputEvent<MouseEvent>;
mousemove: FormInputEvent<MouseEvent>;
paste: FormInputEvent<ClipboardEvent>;
input: FormInputEvent<InputEvent>;
wheel: FormInputEvent<WheelEvent>;
};
export {
Root,
//
Root as Input
};

View file

@ -0,0 +1,42 @@
<script lang="ts">
import type { HTMLInputAttributes } from 'svelte/elements';
import type { InputEvents } from './index.js';
import { cn } from '$lib/utils.js';
type $$Props = HTMLInputAttributes;
type $$Events = InputEvents;
let className: $$Props['class'] = undefined;
export let value: $$Props['value'] = undefined;
export { className as class };
// Workaround for https://github.com/sveltejs/svelte/issues/9305
// Fixed in Svelte 5, but not backported to 4.x.
export let readonly: $$Props['readonly'] = undefined;
</script>
<input
class={cn(
'flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
className
)}
bind:value
{readonly}
on:blur
on:change
on:click
on:focus
on:focusin
on:focusout
on:keydown
on:keypress
on:keyup
on:mouseover
on:mouseenter
on:mouseleave
on:mousemove
on:paste
on:input
on:wheel|passive
{...$$restProps}
/>

View file

@ -0,0 +1,11 @@
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import { env } from '$env/dynamic/private';
import * as schema from './schema';
if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
export const sql = postgres(env.DATABASE_URL);
export const db = drizzle(sql, {
schema,
logger: true
});

View file

@ -0,0 +1 @@
export * from '../../../../../db/schema';

View file

@ -0,0 +1,56 @@
import { type ClassValue, clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { cubicOut } from 'svelte/easing';
import type { TransitionConfig } from 'svelte/transition';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
type FlyAndScaleParams = {
y?: number;
x?: number;
start?: number;
duration?: number;
};
export const flyAndScale = (
node: Element,
params: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 }
): TransitionConfig => {
const style = getComputedStyle(node);
const transform = style.transform === 'none' ? '' : style.transform;
const scaleConversion = (valueA: number, scaleA: [number, number], scaleB: [number, number]) => {
const [minA, maxA] = scaleA;
const [minB, maxB] = scaleB;
const percentage = (valueA - minA) / (maxA - minA);
const valueB = percentage * (maxB - minB) + minB;
return valueB;
};
const styleToString = (style: Record<string, number | string | undefined>): string => {
return Object.keys(style).reduce((str, key) => {
if (style[key] === undefined) return str;
return str + `${key}:${style[key]};`;
}, '');
};
return {
duration: params.duration ?? 200,
delay: 0,
css: (t) => {
const y = scaleConversion(t, [0, 1], [params.y ?? 5, 0]);
const x = scaleConversion(t, [0, 1], [params.x ?? 0, 0]);
const scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1]);
return styleToString({
transform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`,
opacity: t
});
},
easing: cubicOut
};
};

View file

@ -0,0 +1,26 @@
<script>
// import { cubicIn, cubicOut } from 'svelte/easing';
import '../app.css';
// import { fly } from 'svelte/transition';
export let data;
</script>
<svelte:head>
{#if import.meta.env.PROD}
<script
defer
src="https://umami.experimentos.nulo.ar/script.js"
data-website-id="3d9215d1-f15c-4797-abff-d621da254930"
></script>
{/if}
</svelte:head>
<!-- {#key data.pathname}
<div
in:fly={{ easing: cubicOut, x: 10, duration: 150, delay: 300 }}
out:fly={{ easing: cubicIn, x: -10, duration: 150 }}
> -->
<slot />
<!-- </div>
{/key} -->

View file

@ -0,0 +1,7 @@
export const load = ({ url }) => {
const { pathname } = url;
return {
pathname
};
};

View file

@ -0,0 +1,15 @@
import { sql } from '$lib/server/db';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async () => {
// https://www.cybertec-postgresql.com/en/postgresql-count-made-fast/
const count = await sql`
SELECT reltuples::bigint
FROM pg_catalog.pg_class
WHERE relname = 'precios';
`;
return {
count: count[0].reltuples
};
};

View file

@ -0,0 +1,31 @@
<script lang="ts">
import SearchBar from '$lib/components/SearchBar.svelte';
import type { PageData } from './$types';
const numberFormat = new Intl.NumberFormat('es-AR', {
style: 'decimal'
});
export let data: PageData;
</script>
<div class="mx-auto max-w-screen-sm p-4">
<h1 class="my-4 flex text-5xl font-bold">
preciazo<small class="text-sm">alpha</small>
</h1>
<h2 class="my-4 text-lg font-medium text-gray-700">
¡actualmente tengo {numberFormat.format(data.count)} registros de precios!
</h2>
<SearchBar />
<footer class="prose my-4 text-sm text-gray-700">
preciazo es una iniciativa de <a
href="https://nulo.in/"
target="_blank"
rel="noopener noreferrer">Nulo</a
>. usa la base de datos abierta
<a href="https://datos.produccion.gob.ar/dataset/sepa-precios">Precios Claros - Base SEPA</a>
del Ministerio de Economía. podes contactarme en
<a href="mailto:hola@nulo.in">hola@nulo.in</a>. twitter:
<a href="https://x.com/esoesnulo" target="_blank" rel="noopener noreferrer">@esoesnulo</a>.
</footer>
</div>

View file

@ -0,0 +1,107 @@
import { db } from '$lib/server/db';
import type { PageServerLoad } from './$types';
import { datasets, precios, sucursales } from '$lib/server/db/schema';
import { and, eq, sql } from 'drizzle-orm';
export const load: PageServerLoad = async ({ params }) => {
const id = BigInt(params.id);
const preciosRes = await db
.select({
id_comercio: precios.id_comercio,
id_bandera: precios.id_bandera,
id_sucursal: precios.id_sucursal,
id_dataset: precios.id_dataset,
productos_precio_lista: precios.productos_precio_lista,
productos_descripcion: precios.productos_descripcion,
sucursales_latitud: sucursales.sucursales_latitud,
sucursales_longitud: sucursales.sucursales_longitud,
sucursales_nombre: sucursales.sucursales_nombre,
sucursales_calle: sucursales.sucursales_calle,
sucursales_numero: sucursales.sucursales_numero,
dataset_date: datasets.date
})
.from(precios)
.where(
and(
eq(precios.id_producto, BigInt(params.id)),
sql`${precios.id_dataset} IN (
SELECT d1.id
FROM datasets d1
JOIN (
SELECT id_comercio, MAX(date) as max_date
FROM datasets
GROUP BY id_comercio
) d2 ON d1.id_comercio = d2.id_comercio AND d1.date = d2.max_date
ORDER BY d1.id_comercio)
`
)
)
.leftJoin(
sucursales,
and(
eq(sucursales.id_dataset, precios.id_dataset),
eq(sucursales.id_sucursal, precios.id_sucursal),
eq(sucursales.id_comercio, precios.id_comercio)
)
)
.leftJoin(datasets, eq(datasets.id, precios.id_dataset));
// const precios = await sql<
// {
// productos_precio_lista: number;
// productos_descripcion: string;
// id_dataset: string;
// sucursales_latitud: number;
// sucursales_longitud: number;
// sucursales_nombre: string;
// }[]
// >`
// WITH latest_prices AS (
// SELECT
// p.id_comercio,
// p.id_bandera,
// p.id_sucursal,
// p.id_dataset,
// p.productos_precio_lista,
// p.productos_descripcion
// FROM precios p
// INNER JOIN (
// SELECT
// id_comercio,
// id_bandera,
// id_sucursal,
// MAX(id_dataset) AS max_dataset
// FROM precios
// WHERE id_producto = ${id}
// GROUP BY id_comercio, id_bandera, id_sucursal
// ) latest ON p.id_comercio = latest.id_comercio
// AND p.id_bandera = latest.id_bandera
// AND p.id_sucursal = latest.id_sucursal
// AND p.id_dataset = latest.max_dataset
// WHERE p.id_producto = ${id}
// )
// SELECT
// lp.productos_precio_lista,
// lp.productos_descripcion,
// lp.id_dataset,
// s.sucursales_latitud,
// s.sucursales_longitud,
// s.sucursales_nombre
// FROM latest_prices lp
// LEFT JOIN sucursales s ON lp.id_dataset = s.id_dataset
// AND lp.id_sucursal = s.id_sucursal
// AND lp.id_comercio = s.id_comercio
// `;
return {
precios: preciosRes.map((p) => ({
...p,
productos_precio_lista: parseFloat(p.productos_precio_lista ?? '0'),
sucursales_latitud: parseFloat(p.sucursales_latitud ?? '0'),
sucursales_longitud: parseFloat(p.sucursales_longitud ?? '0')
})),
id_producto: id
};
};

View file

@ -0,0 +1,104 @@
<script lang="ts">
import type { PageData } from './$types';
import { ArrowLeft } from 'lucide-svelte';
import Map from '$lib/components/Map.svelte';
import Badge from '$lib/components/ui/badge/badge.svelte';
import {} from '$app/navigation';
export let data: PageData;
const pesosFormatter = new Intl.NumberFormat('es-AR', {
style: 'currency',
currency: 'ARS'
});
</script>
<svelte:head>
<title>{data.precios[0].productos_descripcion} - Preciazo</title>
</svelte:head>
<div class="flex min-h-screen flex-col">
<div class="max-w-screen flex items-stretch gap-3 overflow-hidden px-2">
<button on:click={() => window.history.back()}>
<ArrowLeft class="size-8 flex-shrink-0" />
</button>
<div class="flex flex-wrap items-center gap-x-2 overflow-hidden p-1">
<h1 class="overflow-hidden text-ellipsis whitespace-nowrap pb-1 text-2xl font-bold">
{data.precios[0].productos_descripcion}
</h1>
<Badge>{data.precios.length} precios</Badge>
<Badge variant="outline">EAN {data.id_producto}</Badge>
</div>
</div>
<Map
mapMap={(map, L) => {
// var markers = L.MarkerClusterGroup();
const myRenderer = L.canvas({ padding: 0.5 });
const prices = data.precios.map((p) => p.productos_precio_lista);
const sortedPrices = prices.sort((a, b) => a - b);
const q1Index = Math.floor(sortedPrices.length * 0.1);
const q3Index = Math.floor(sortedPrices.length * 0.9);
const iqr = sortedPrices[q3Index] - sortedPrices[q1Index];
const lowerBound = sortedPrices[q1Index] - 1.5 * iqr;
const upperBound = sortedPrices[q3Index] + 1.5 * iqr;
const filteredPrices = sortedPrices.filter((p) => p >= lowerBound && p <= upperBound);
const min = Math.min(...filteredPrices);
const max = Math.max(...filteredPrices);
console.log({ min, max, outliers: prices.length - filteredPrices.length });
// For each row in data, create a marker and add it to the map
// For each row, columns `Latitude`, `Longitude`, and `Title` are required
for (const precio of data.precios) {
const normalizedPrice = (precio.productos_precio_lista - min) / (max - min);
// Safari doesn't support color-mix, so we'll use a fallback
const color = getSafeColor(normalizedPrice);
const createElement = () => {
const div = document.createElement('div');
[
`fecha del precio: ${precio.dataset_date}`,
`precio: ${pesosFormatter.format(precio.productos_precio_lista)}`,
`sucursal: ${precio.sucursales_nombre}`,
`dirección: ${precio.sucursales_calle} ${precio.sucursales_numero}`,
() => {
const a = document.createElement('a');
const params = new URLSearchParams({
query: `${precio.sucursales_calle} ${precio.sucursales_numero}`
});
a.href = `https://www.google.com/maps/search/?api=1&${params.toString()}`;
a.target = '_blank';
a.append('ver en Google Maps');
return a;
},
`descripcion del producto segun el comercio: ${precio.productos_descripcion}`
].forEach((el) => {
div.append(typeof el === 'function' ? el() : el);
div.append(document.createElement('br'));
});
return div;
};
var marker = L.circleMarker([precio.sucursales_latitud, precio.sucursales_longitud], {
opacity: 1,
renderer: myRenderer,
color,
radius: 5
})
.bindPopup(createElement)
.addTo(map);
marker.on('click', function (this: L.CircleMarker) {
this.openPopup();
});
}
// Helper function to get a color that works in Safari
function getSafeColor(normalizedPrice: number) {
const r = Math.round(255 * normalizedPrice);
const g = Math.round(255 * (1 - normalizedPrice));
return `rgb(${r}, ${g}, 0)`;
}
}}
/>
</div>

View file

@ -0,0 +1,131 @@
import { db } from '$lib/server/db';
import { sql } from 'drizzle-orm';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ params }) => {
// const latestDatasetsSq = db.$with('latest_datasets').as(
// db.select({
// id: datasets.id,
// }).from(datasets)
// .innerJoin(
// db.select({
// id_comercio: datasets.id_comercio,
// max_date: max(datasets.date),
// }).from(d2).groupBy(datasets.id_comercio),
// and(eq(datasets.id_comercio, d2.id_comercio), eq(datasets.date, d2.max_date))
// // 'datasets.id_comercio = latest_datasets.id_comercio AND datasets.date = latest_datasets.max_date'
// ))
const query = params.query;
const productos = await db.execute<{
id_producto: string;
productos_descripcion: string;
productos_marca: string;
in_datasets_count: number;
}>(sql`
SELECT id_producto, productos_descripcion, productos_marca,
(WITH latest_datasets AS (
SELECT d1.id
FROM datasets d1
JOIN (
SELECT id_comercio, MAX(date) as max_date
FROM datasets
GROUP BY id_comercio
) d2 ON d1.id_comercio = d2.id_comercio AND d1.date = d2.max_date
)SELECT COUNT(DISTINCT p.id_dataset) as dataset_count
FROM precios p
JOIN latest_datasets ld ON p.id_dataset = ld.id
WHERE p.id_producto = index.id_producto) as in_datasets_count
FROM productos_descripcion_index index
WHERE productos_descripcion ILIKE ${`%${query}%`}
ORDER BY in_datasets_count desc
LIMIT 100
`);
const collapsedProductos = productos.reduce(
(acc, producto) => {
const existingProduct = acc.find((p) => p.id_producto === producto.id_producto);
if (existingProduct) {
existingProduct.descriptions.push(producto.productos_descripcion);
existingProduct.marcas.add(producto.productos_marca);
existingProduct.in_datasets_count = Math.max(
existingProduct.in_datasets_count,
producto.in_datasets_count
);
} else {
acc.push({
id_producto: producto.id_producto,
descriptions: [producto.productos_descripcion],
marcas: new Set([producto.productos_marca]),
in_datasets_count: producto.in_datasets_count
});
}
return acc;
},
[] as Array<{
id_producto: string;
descriptions: string[];
marcas: Set<string>;
in_datasets_count: number;
}>
);
// 'latest_datasets',
// sql`
// WITH latest_datasets AS (
// SELECT d1.id
// FROM datasets d1
// JOIN (
// SELECT id_comercio, MAX(date) as max_date
// FROM datasets
// GROUP BY id_comercio
// ) d2 ON d1.id_comercio = d2.id_comercio AND d1.date = d2.max_date
// )`
// .select({
// id_producto: productos_descripcion_index.id_producto,
// productos_descripcion: productos_descripcion_index.productos_descripcion,
// productos_marca: productos_descripcion_index.productos_marca,
// })
// .from(productos_descripcion_index)
// .where(ilike(productos_descripcion_index.productos_descripcion, `%${query}%`))
// .orderBy(sql`
// WITH latest_datasets AS (
// SELECT d1.id
// FROM datasets d1
// JOIN (
// SELECT id_comercio, MAX(date) as max_date
// FROM datasets
// GROUP BY id_comercio
// ) d2 ON d1.id_comercio = d2.id_comercio AND d1.date = d2.max_date
// )
// SELECT COUNT(DISTINCT p.id_dataset) as dataset_count
// FROM precios p
// JOIN latest_datasets ld ON p.id_dataset = ld.id
// WHERE p.id_producto = ${productos_descripcion_index.id_producto}`);
return { productos, collapsedProductos, query };
// const precios = await sql<
// {
// id_producto: string;
// productos_precio_lista: number;
// productos_descripcion: string;
// }[]
// >`
// WITH latest_prices AS (
// SELECT DISTINCT ON (id_comercio, id_producto)
// id_comercio,
// id_producto,
// productos_precio_lista,
// productos_descripcion
// FROM precios
// )
// SELECT
// id_producto,
// productos_precio_lista,
// productos_descripcion
// FROM latest_prices
// WHERE productos_descripcion ILIKE ${`%${query}%`}
// `;
// return {
// precios
// };
};

View file

@ -0,0 +1,48 @@
<script lang="ts">
import SearchBar from '$lib/components/SearchBar.svelte';
import Badge from '$lib/components/ui/badge/badge.svelte';
import Button from '$lib/components/ui/button/button.svelte';
import * as Card from '$lib/components/ui/card/index.js';
import { ArrowLeft } from 'lucide-svelte';
import type { PageData } from './$types';
import { goto } from '$app/navigation';
export let data: PageData;
</script>
<svelte:head>
<title>Resultados para "{data.query}" - Preciazo</title>
</svelte:head>
<div class="mx-auto max-w-screen-sm p-4">
<Button on:click={() => goto('/')} class="mb-2 gap-1" variant="outline">
<ArrowLeft />
Volver al inicio
</Button>
<SearchBar />
<h1 class="my-2 text-2xl font-bold">Resultados para "{data.query}"</h1>
{#each data.collapsedProductos as producto}
<a href={`/id_producto/${producto.id_producto}`} class="my-2 block">
<Card.Root class="transition-colors duration-200 hover:bg-gray-100">
<Card.Header class="block px-3 py-2 pb-0">
<Badge
>{Array.from(producto.marcas)
.filter((m) => !['sin marca', 'VARIOS'].includes(m))
.filter((m) => m?.trim().length > 0)
.join('/')}</Badge
>
<Badge variant="outline">en {producto.in_datasets_count} cadenas</Badge>
<Badge variant="outline">EAN {producto.id_producto}</Badge>
</Card.Header>
<Card.Content class="px-3 py-2">
{#each producto.descriptions as description}
<span>{description}</span>
{#if description !== producto.descriptions[producto.descriptions.length - 1]}
<span class="text-gray-500"></span>{' '}
{/if}
{/each}
</Card.Content>
</Card.Root>
</a>
{/each}
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -0,0 +1,19 @@
// import adapter from '@sveltejs/adapter-auto';
import adapter from 'svelte-adapter-bun';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess(),
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter()
}
};
export default config;

View file

@ -0,0 +1,69 @@
import { fontFamily } from 'tailwindcss/defaultTheme';
import type { Config } from 'tailwindcss';
import typography from '@tailwindcss/typography';
const config: Config = {
darkMode: ['class'],
content: ['./src/**/*.{html,js,svelte,ts}'],
safelist: ['dark'],
theme: {
container: {
center: true,
padding: '2rem',
screens: {
'2xl': '1400px'
}
},
extend: {
colors: {
border: 'hsl(var(--border) / <alpha-value>)',
input: 'hsl(var(--input) / <alpha-value>)',
ring: 'hsl(var(--ring) / <alpha-value>)',
background: 'hsl(var(--background) / <alpha-value>)',
foreground: 'hsl(var(--foreground) / <alpha-value>)',
primary: {
DEFAULT: 'hsl(var(--primary) / <alpha-value>)',
foreground: 'hsl(var(--primary-foreground) / <alpha-value>)'
},
secondary: {
DEFAULT: 'hsl(var(--secondary) / <alpha-value>)',
foreground: 'hsl(var(--secondary-foreground) / <alpha-value>)'
},
destructive: {
DEFAULT: 'hsl(var(--destructive) / <alpha-value>)',
foreground: 'hsl(var(--destructive-foreground) / <alpha-value>)'
},
muted: {
DEFAULT: 'hsl(var(--muted) / <alpha-value>)',
foreground: 'hsl(var(--muted-foreground) / <alpha-value>)'
},
accent: {
DEFAULT: 'hsl(var(--accent) / <alpha-value>)',
foreground: 'hsl(var(--accent-foreground) / <alpha-value>)'
},
popover: {
DEFAULT: 'hsl(var(--popover) / <alpha-value>)',
foreground: 'hsl(var(--popover-foreground) / <alpha-value>)'
},
card: {
DEFAULT: 'hsl(var(--card) / <alpha-value>)',
foreground: 'hsl(var(--card-foreground) / <alpha-value>)'
}
},
borderRadius: {
lg: 'var(--radius)',
md: 'calc(var(--radius) - 2px)',
sm: 'calc(var(--radius) - 4px)'
},
fontFamily: {
sans: [...fontFamily.sans]
}
}
},
plugins: [
typography
// ...
]
};
export default config;

19
sepa/sitio2/tsconfig.json Normal file
View file

@ -0,0 +1,19 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
// except $lib which is handled by https://kit.svelte.dev/docs/configuration#files
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}

View file

@ -0,0 +1,16 @@
import { sentrySvelteKit } from '@sentry/sveltekit';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
sentrySvelteKit({
sourceMapsUploadOptions: {
org: 'nulo-inc',
project: 'preciazo-sitio2',
url: 'https://sentry.io/'
}
}),
sveltekit()
]
});