refactor: optimize vacation data aggregation and logging
- Updated the logic for aggregating approved vacation requests to streamline data handling and improve performance. - Enhanced logging to provide detailed insights into vacation periods and requests, aiding in debugging and monitoring. - Cleaned up code formatting for better readability and maintainability, ensuring a consistent coding style throughout the component.
This commit is contained in:
@@ -201,7 +201,8 @@
|
||||
|
||||
const solicitacoesAprovadas = $derived(
|
||||
solicitacoesFiltradas.filter(
|
||||
(p) => p.status === 'aprovado' || p.status === 'data_ajustada_aprovada' || p.status === 'EmFérias'
|
||||
(p) =>
|
||||
p.status === 'aprovado' || p.status === 'data_ajustada_aprovada' || p.status === 'EmFérias'
|
||||
)
|
||||
);
|
||||
|
||||
@@ -304,19 +305,16 @@
|
||||
(() => {
|
||||
const agregados = new SvelteMap<number, SolicitacoesPorAnoResumo>();
|
||||
|
||||
for (const solicitacao of solicitacoesAprovadas) {
|
||||
const totalDias = solicitacao.periodos.reduce(
|
||||
(acc, periodo) => acc + periodo.diasFerias,
|
||||
0
|
||||
);
|
||||
const existente = agregados.get(solicitacao.anoReferencia) ?? {
|
||||
ano: solicitacao.anoReferencia,
|
||||
for (const periodo of solicitacoesAprovadas) {
|
||||
const totalDias = periodo.diasFerias;
|
||||
const existente = agregados.get(periodo.anoReferencia) ?? {
|
||||
ano: periodo.anoReferencia,
|
||||
solicitacoes: 0,
|
||||
diasTotais: 0
|
||||
};
|
||||
existente.solicitacoes += 1;
|
||||
existente.diasTotais += totalDias;
|
||||
agregados.set(solicitacao.anoReferencia, existente);
|
||||
agregados.set(periodo.anoReferencia, existente);
|
||||
}
|
||||
|
||||
return Array.from(agregados.values()).sort((a, b) => a.ano - b.ano);
|
||||
@@ -460,9 +458,18 @@
|
||||
console.log('📅 [Eventos] Total de eventos:', eventosFerias.length);
|
||||
console.log('📋 [Periodos] Total de períodos:', periodosDetalhados.length);
|
||||
console.log('✅ [Aprovadas] Total de solicitações aprovadas:', solicitacoesAprovadas.length);
|
||||
console.log('📊 [PeriodosPorMes] Total:', periodosPorMes.length);
|
||||
console.log('📊 [PeriodosPorMesAtivos] Total:', periodosPorMesAtivos.length);
|
||||
console.log('📊 [SolicitacoesPorAno] Total:', solicitacoesPorAno.length);
|
||||
if (eventosFerias.length > 0) {
|
||||
console.log('📅 [Eventos] Primeiro evento:', eventosFerias[0]);
|
||||
}
|
||||
if (periodosPorMes.length > 0) {
|
||||
console.log('📊 [PeriodosPorMes] Primeiro:', periodosPorMes[0]);
|
||||
}
|
||||
if (solicitacoesPorAno.length > 0) {
|
||||
console.log('📊 [SolicitacoesPorAno] Primeiro:', solicitacoesPorAno[0]);
|
||||
}
|
||||
});
|
||||
|
||||
let calendarioContainer: HTMLDivElement | null = null;
|
||||
@@ -1709,10 +1716,7 @@
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
{#if periodo.time}
|
||||
<div
|
||||
class="badge badge-outline"
|
||||
style="border-color: {periodo.time.cor}"
|
||||
{#if periodo.time}
|
||||
<div class="badge badge-outline" style="border-color: {periodo.time.cor}">
|
||||
{periodo.time.nome}
|
||||
</div>
|
||||
@@ -1721,7 +1725,9 @@
|
||||
{/if}
|
||||
</td>
|
||||
<td>{periodo.anoReferencia}</td>
|
||||
<td>
|
||||
<td>
|
||||
{formatarDataString(periodo.dataInicio)} - {formatarDataString(
|
||||
periodo.dataFim
|
||||
)}
|
||||
</td>
|
||||
<td class="text-base-content font-bold">{periodo.diasFerias} dia(s)</td>
|
||||
|
||||
Reference in New Issue
Block a user