Actualizar server.js
This commit is contained in:
@@ -2881,8 +2881,10 @@ app.get("/public/portal/:token/location/:serviceId", async (req, res) => {
|
||||
app.get("/public/assignment/:token", async (req, res) => {
|
||||
try {
|
||||
const { token } = req.params;
|
||||
// 🧠 AÑADIDO: Subconsulta mágica para sacar el nombre real del Gremio
|
||||
const q = await pool.query(`
|
||||
SELECT ap.*, s.raw_data, s.service_ref, s.is_urgent, u.full_name
|
||||
SELECT ap.*, s.raw_data, s.service_ref, s.is_urgent, u.full_name,
|
||||
(SELECT name FROM guilds WHERE id::text = s.raw_data->>'guild_id' LIMIT 1) as real_guild_name
|
||||
FROM assignment_pings ap
|
||||
JOIN scraped_services s ON ap.scraped_id = s.id
|
||||
JOIN users u ON ap.user_id = u.id
|
||||
@@ -2905,8 +2907,9 @@ app.get("/public/assignment/:token", async (req, res) => {
|
||||
// Parsear datos para enviarlos bonitos a la pantalla de aceptar.html
|
||||
const raw = assign.raw_data || {};
|
||||
const serviceData = {
|
||||
"Gremio": raw["Gremio"] || raw.guild_name || "Servicio General",
|
||||
"Gremio": assign.real_guild_name || raw["Gremio"] || raw.guild_name || "Servicio General",
|
||||
"Expediente": assign.service_ref || raw["Referencia"] || "Sin Ref",
|
||||
"Dirección": raw["Dirección"] || raw["DOMICILIO"] || "",
|
||||
"Población": raw["Población"] || raw["POBLACION-PROVINCIA"] || "",
|
||||
"Código Postal": raw["Código Postal"] || "",
|
||||
"Descripción": raw["Descripción"] || raw["DESCRIPCION"] || "Revisar en el lugar."
|
||||
|
||||
Reference in New Issue
Block a user