ux improved

This commit is contained in:
Lucas Tettamanti
2026-01-17 04:13:35 -03:00
parent 98e3d78e3d
commit 63b9ecef61
35 changed files with 4266 additions and 75 deletions

View File

@@ -0,0 +1,24 @@
-- migrate:up
create table if not exists product_reco_rules (
id bigserial primary key,
tenant_id uuid not null references tenants(id) on delete cascade,
rule_key text not null,
trigger jsonb not null default '{}'::jsonb,
queries jsonb not null default '[]'::jsonb,
boosts jsonb not null default '{}'::jsonb,
ask_slots jsonb not null default '[]'::jsonb,
active boolean not null default true,
priority integer not null default 100,
created_at timestamptz not null default now(),
updated_at timestamptz not null default now(),
unique (tenant_id, rule_key)
);
create index if not exists product_reco_rules_tenant_idx
on product_reco_rules (tenant_id);
create index if not exists product_reco_rules_active_idx
on product_reco_rules (tenant_id, active, priority);
-- migrate:down
drop table if exists product_reco_rules;

View File

@@ -0,0 +1,49 @@
-- migrate:up
insert into product_reco_rules
(tenant_id, rule_key, trigger, queries, boosts, ask_slots, active, priority)
select
t.id as tenant_id,
'asado_core' as rule_key,
jsonb_build_object(
'keywords', jsonb_build_array('asado', 'parrilla', 'bife', 'entraña', 'vacio', 'vacío')
) as trigger,
jsonb_build_array('provoleta', 'chimichurri', 'ensalada', 'pan') as queries,
'{}'::jsonb as boosts,
jsonb_build_array(
jsonb_build_object('slot','alcohol','question','¿Tomás alcohol?')
) as ask_slots,
true as active,
100 as priority
from tenants t
on conflict (tenant_id, rule_key) do nothing;
insert into product_reco_rules
(tenant_id, rule_key, trigger, queries, boosts, ask_slots, active, priority)
select
t.id as tenant_id,
'alcohol_yes' as rule_key,
jsonb_build_object('always', true, 'alcohol', true) as trigger,
jsonb_build_array('vino tinto', 'malbec', 'cabernet') as queries,
'{}'::jsonb as boosts,
'[]'::jsonb as ask_slots,
true as active,
200 as priority
from tenants t
on conflict (tenant_id, rule_key) do nothing;
insert into product_reco_rules
(tenant_id, rule_key, trigger, queries, boosts, ask_slots, active, priority)
select
t.id as tenant_id,
'alcohol_no' as rule_key,
jsonb_build_object('always', true, 'alcohol', false) as trigger,
jsonb_build_array('agua con gas', 'gaseosa', 'limonada') as queries,
'{}'::jsonb as boosts,
'[]'::jsonb as ask_slots,
true as active,
210 as priority
from tenants t
on conflict (tenant_id, rule_key) do nothing;
-- migrate:down
delete from product_reco_rules where rule_key in ('asado_core','alcohol_yes','alcohol_no');