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(
|
const solicitacoesAprovadas = $derived(
|
||||||
solicitacoesFiltradas.filter(
|
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>();
|
const agregados = new SvelteMap<number, SolicitacoesPorAnoResumo>();
|
||||||
|
|
||||||
for (const solicitacao of solicitacoesAprovadas) {
|
for (const periodo of solicitacoesAprovadas) {
|
||||||
const totalDias = solicitacao.periodos.reduce(
|
const totalDias = periodo.diasFerias;
|
||||||
(acc, periodo) => acc + periodo.diasFerias,
|
const existente = agregados.get(periodo.anoReferencia) ?? {
|
||||||
0
|
ano: periodo.anoReferencia,
|
||||||
);
|
|
||||||
const existente = agregados.get(solicitacao.anoReferencia) ?? {
|
|
||||||
ano: solicitacao.anoReferencia,
|
|
||||||
solicitacoes: 0,
|
solicitacoes: 0,
|
||||||
diasTotais: 0
|
diasTotais: 0
|
||||||
};
|
};
|
||||||
existente.solicitacoes += 1;
|
existente.solicitacoes += 1;
|
||||||
existente.diasTotais += totalDias;
|
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);
|
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('📅 [Eventos] Total de eventos:', eventosFerias.length);
|
||||||
console.log('📋 [Periodos] Total de períodos:', periodosDetalhados.length);
|
console.log('📋 [Periodos] Total de períodos:', periodosDetalhados.length);
|
||||||
console.log('✅ [Aprovadas] Total de solicitações aprovadas:', solicitacoesAprovadas.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) {
|
if (eventosFerias.length > 0) {
|
||||||
console.log('📅 [Eventos] Primeiro evento:', eventosFerias[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;
|
let calendarioContainer: HTMLDivElement | null = null;
|
||||||
@@ -1709,10 +1716,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{#if periodo.time}
|
{#if periodo.time}
|
||||||
<div
|
|
||||||
class="badge badge-outline"
|
|
||||||
style="border-color: {periodo.time.cor}"
|
|
||||||
<div class="badge badge-outline" style="border-color: {periodo.time.cor}">
|
<div class="badge badge-outline" style="border-color: {periodo.time.cor}">
|
||||||
{periodo.time.nome}
|
{periodo.time.nome}
|
||||||
</div>
|
</div>
|
||||||
@@ -1721,7 +1725,9 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
<td>{periodo.anoReferencia}</td>
|
<td>{periodo.anoReferencia}</td>
|
||||||
<td>
|
<td>
|
||||||
|
{formatarDataString(periodo.dataInicio)} - {formatarDataString(
|
||||||
|
periodo.dataFim
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td class="text-base-content font-bold">{periodo.diasFerias} dia(s)</td>
|
<td class="text-base-content font-bold">{periodo.diasFerias} dia(s)</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user