adicionado 0 na escal de nota
This commit is contained in:
parent
0bbd04ee45
commit
e8ca410b94
8 changed files with 72 additions and 15 deletions
|
|
@ -40,8 +40,8 @@ ORDER BY tablename`)
|
|||
|
||||
// NPSMesAMes calcula o NPS por mês para um produto (tabela `nps_{produto}`).
|
||||
//
|
||||
// Regra NPS (1–10):
|
||||
// - 1–6 detratores
|
||||
// Regra NPS (0–10):
|
||||
// - 0–6 detratores
|
||||
// - 7–8 neutros
|
||||
// - 9–10 promotores
|
||||
func (s *Store) NPSMesAMes(ctx context.Context, tabela string, meses int) ([]contratos.NPSMensal, error) {
|
||||
|
|
@ -62,7 +62,7 @@ WITH base AS (
|
|||
)
|
||||
SELECT
|
||||
to_char(mes, 'YYYY-MM') AS mes,
|
||||
SUM(CASE WHEN nota BETWEEN 1 AND 6 THEN 1 ELSE 0 END)::int AS detratores,
|
||||
SUM(CASE WHEN nota BETWEEN 0 AND 6 THEN 1 ELSE 0 END)::int AS detratores,
|
||||
SUM(CASE WHEN nota BETWEEN 7 AND 8 THEN 1 ELSE 0 END)::int AS neutros,
|
||||
SUM(CASE WHEN nota BETWEEN 9 AND 10 THEN 1 ELSE 0 END)::int AS promotores,
|
||||
COUNT(*)::int AS total
|
||||
|
|
@ -116,7 +116,7 @@ func (s *Store) ListarRespostas(ctx context.Context, tabela string, filtro Lista
|
|||
|
||||
cond := "status='respondido' AND valida=true"
|
||||
if filtro.SomenteNotasBaixas {
|
||||
cond += " AND nota BETWEEN 1 AND 6"
|
||||
cond += " AND nota BETWEEN 0 AND 6"
|
||||
}
|
||||
|
||||
// Importante (segurança): apesar do cond ser construído em string, ele NÃO usa
|
||||
|
|
@ -180,7 +180,7 @@ func (s *Store) ExportarRespostas(ctx context.Context, tabela string, filtro Exp
|
|||
|
||||
cond := "status='respondido' AND valida=true"
|
||||
if filtro.SomenteNotasBaixas {
|
||||
cond += " AND nota BETWEEN 1 AND 6"
|
||||
cond += " AND nota BETWEEN 0 AND 6"
|
||||
}
|
||||
|
||||
// Sem LIMIT/OFFSET (export completo).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue