fix(admin): corrigir coalesce de preco para priorizar price_monthly sobre price=0
Build and Deploy (Gitea Actions) / build-and-deploy (push) Successful in 2m44s Details

This commit is contained in:
Sidney 2026-07-19 20:14:25 -03:00
parent cbf8b639e8
commit b105fd2151
1 changed files with 4 additions and 4 deletions

View File

@ -5,8 +5,8 @@ export async function GET() {
try { try {
let res = await query(` let res = await query(`
SELECT p.id, p.name, COALESCE(p.slug, LOWER(p.name)) as slug, SELECT p.id, p.name, COALESCE(p.slug, LOWER(p.name)) as slug,
COALESCE(p.price, p.price_monthly, 0) as "priceMonthly", COALESCE(NULLIF(p.price_monthly, 0), NULLIF(p.price, 0), 0) as "priceMonthly",
COALESCE(p.price_yearly, p.price * 10, 0) as "priceYearly", COALESCE(NULLIF(p.price_yearly, 0), p.price * 10, 0) as "priceYearly",
COALESCE(p.max_professionals, 1) as "maxProfessionals", COALESCE(p.max_professionals, 1) as "maxProfessionals",
COALESCE(p.max_services, 10) as "maxServices", COALESCE(p.max_services, 10) as "maxServices",
p.features, p.is_active as active, p.features, p.is_active as active,
@ -34,8 +34,8 @@ export async function GET() {
res = await query(` res = await query(`
SELECT p.id, p.name, COALESCE(p.slug, LOWER(p.name)) as slug, SELECT p.id, p.name, COALESCE(p.slug, LOWER(p.name)) as slug,
COALESCE(p.price, p.price_monthly, 0) as "priceMonthly", COALESCE(NULLIF(p.price_monthly, 0), NULLIF(p.price, 0), 0) as "priceMonthly",
COALESCE(p.price_yearly, p.price * 10, 0) as "priceYearly", COALESCE(NULLIF(p.price_yearly, 0), p.price * 10, 0) as "priceYearly",
COALESCE(p.max_professionals, 1) as "maxProfessionals", COALESCE(p.max_professionals, 1) as "maxProfessionals",
COALESCE(p.max_services, 10) as "maxServices", COALESCE(p.max_services, 10) as "maxServices",
p.features, p.is_active as active, p.features, p.is_active as active,