mover logica de supermercado a db-datos

This commit is contained in:
Cat /dev/Nulo 2023-12-25 00:15:19 -03:00
parent 1d4133e1c8
commit a8d26f32a5
2 changed files with 17 additions and 17 deletions

16
db-datos/supermercado.ts Normal file
View file

@ -0,0 +1,16 @@
export enum Supermercado {
Dia = "Dia",
Carrefour = "Carrefour",
Coto = "Coto",
}
export const hosts: { [host: string]: Supermercado } = {
"diaonline.supermercadosdia.com.ar": Supermercado.Dia,
"www.carrefour.com.ar": Supermercado.Carrefour,
"www.cotodigital3.com.ar": Supermercado.Coto,
};
export const colorBySupermercado: { [supermercado in Supermercado]: string } = {
[Supermercado.Dia]: "#d52b1e",
[Supermercado.Carrefour]: "#19549d",
[Supermercado.Coto]: "#e20025",
};

View file

@ -2,26 +2,10 @@
import type { Precio } from "db-datos/schema"; import type { Precio } from "db-datos/schema";
// import dayjs from "dayjs"; // import dayjs from "dayjs";
import ChartJs from "./ChartJs.svelte"; import ChartJs from "./ChartJs.svelte";
import { hosts, colorBySupermercado } from "db-datos/supermercado";
export let precios: Precio[]; export let precios: Precio[];
enum Supermercado {
Dia = "Dia",
Carrefour = "Carrefour",
Coto = "Coto",
}
const hosts: { [host: string]: Supermercado } = {
"diaonline.supermercadosdia.com.ar": Supermercado.Dia,
"www.carrefour.com.ar": Supermercado.Carrefour,
"www.cotodigital3.com.ar": Supermercado.Coto,
};
const colorBySupermercado: { [supermercado in Supermercado]: string } = {
[Supermercado.Dia]: "#d52b1e",
[Supermercado.Carrefour]: "#19549d",
[Supermercado.Coto]: "#e20025",
};
$: datasets = precios $: datasets = precios
.map((p) => new URL(p.url!).hostname) .map((p) => new URL(p.url!).hostname)
.filter(onlyUnique) .filter(onlyUnique)