refactor: remove mock data and finalize n8n data schema
All checks were successful
Build and Deploy / build-and-push (push) Successful in 1m50s

- Removed all hardcoded MOCK_ATTENDANCES, USERS, and TENANTS generators from constants.ts since the system is now production-ready.

- Renamed 'summary' to 'title' in the database and across all frontend components for clarity.

- Added 'full_summary' to the attendances schema to explicitly store the large, detailed AI analysis texts from n8n.

- Updated the 'Resumo da Interação' UI to render the 'full_summary' without adding any artificial filler text.

- Localized all dates and times across the dashboard to Brazilian formatting (pt-BR).
This commit is contained in:
Cauê Faleiros
2026-03-17 12:45:15 -03:00
parent baa1bd66f6
commit 96cfb3d125
7 changed files with 55 additions and 186 deletions

View File

@@ -796,7 +796,7 @@ apiRouter.get('/search', async (req, res) => {
}
// 4. Search Attendances
let attendancesQ = 'SELECT a.id, a.summary, a.created_at, u.name as user_name FROM attendances a JOIN users u ON a.user_id = u.id WHERE a.summary LIKE ?';
let attendancesQ = 'SELECT a.id, a.title, a.created_at, u.name as user_name FROM attendances a JOIN users u ON a.user_id = u.id WHERE a.title LIKE ?';
const attendancesParams = [queryStr];
if (req.user.role === 'super_admin') {
@@ -959,7 +959,8 @@ apiRouter.post('/integration/attendances', requireRole(['admin']), async (req, r
user_id,
origin,
funnel_stage,
summary,
title,
full_summary,
score,
first_response_time_min,
handling_time_min,
@@ -970,8 +971,8 @@ apiRouter.post('/integration/attendances', requireRole(['admin']), async (req, r
improvement_points
} = req.body;
if (!user_id || !origin || !funnel_stage || !summary) {
return res.status(400).json({ error: 'Campos obrigatórios ausentes: user_id, origin, funnel_stage, summary' });
if (!user_id || !origin || !funnel_stage || !title) {
return res.status(400).json({ error: 'Campos obrigatórios ausentes: user_id, origin, funnel_stage, title' });
}
try {
@@ -982,16 +983,17 @@ apiRouter.post('/integration/attendances', requireRole(['admin']), async (req, r
const attId = `att_${crypto.randomUUID().split('-')[0]}`;
await pool.query(
`INSERT INTO attendances (
id, tenant_id, user_id, summary, score,
id, tenant_id, user_id, title, full_summary, score,
first_response_time_min, handling_time_min,
funnel_stage, origin, product_requested, product_sold,
converted, attention_points, improvement_points
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
[
attId,
req.user.tenant_id,
user_id,
summary,
title,
full_summary || null,
score || 0,
first_response_time_min || 0,
handling_time_min || 0,
@@ -1300,6 +1302,27 @@ const provisionSuperAdmin = async (retries = 10, delay = 10000) => {
console.log('Schema update note (funnel_stage):', err.message);
}
// Add full_summary column for detailed AI analysis
try {
await connection.query("ALTER TABLE attendances ADD COLUMN full_summary TEXT DEFAULT NULL");
} catch (err) {
if (err.code !== 'ER_DUP_FIELDNAME') console.log('Schema update note (full_summary):', err.message);
}
// Rename summary to title
try {
await connection.query("ALTER TABLE attendances RENAME COLUMN summary TO title");
} catch (err) {
if (err.code !== 'ER_BAD_FIELD_ERROR' && err.code !== 'ER_DUP_FIELDNAME') {
// If RENAME COLUMN fails (older mysql), try CHANGE
try {
await connection.query("ALTER TABLE attendances CHANGE COLUMN summary title TEXT");
} catch (e) {
console.log('Schema update note (summary to title):', e.message);
}
}
}
// Create funnels table
await connection.query(`
CREATE TABLE IF NOT EXISTS funnels (