Fases 4, 5 e 6 — Job 1h + Auditoria + Consolidação + Wizard de validação

This commit is contained in:
2026-06-11 12:02:50 -03:00
parent b77fc0122c
commit 90ed705ed8
29 changed files with 1617 additions and 616 deletions

View File

@@ -0,0 +1,30 @@
# app/controllers/api/v1/dashboard_controller.rb
module Api
module V1
class DashboardController < ApplicationController
# GET /api/v1/dashboard/metricas
def metricas
authorize :dashboard, :metricas?
ultimo = HistoricoEstimado.recentes.first
vivo = HistoricoEstimado.calcular_ao_vivo
render json: {
ultimo_registro: ultimo && {
data_hora: ultimo.data_hora,
valor_estimado: ultimo.valor_total_estimado.to_f,
entregas: ultimo.entregas_contadas
},
ao_vivo: {
valor_mes: vivo[:valor],
entregas_mes: vivo[:entregas]
},
historico_24h: HistoricoEstimado
.where(data_hora: 24.hours.ago..Time.current)
.order(:data_hora)
.map { |h| { hora: h.data_hora.strftime('%H:%M'), valor: h.valor_total_estimado.to_f } }
}
end
end
end
end