Show only the total daily hours per project in summary view instead of the times
This commit is contained in:
parent
1ab7fbd12e
commit
a883a556be
1 changed files with 27 additions and 35 deletions
|
|
@ -49,39 +49,36 @@ onMounted(async () => {
|
|||
});
|
||||
|
||||
const summaries = computed(() => {
|
||||
const e = entries.value.filter((el) => {
|
||||
return el.end !== null && el.end.getTime() > el.start.getTime() && el.project !== "";
|
||||
});
|
||||
const hours: { [key: string]: number } = {};
|
||||
|
||||
const minutes: { [key: string]: number } = {};
|
||||
|
||||
for (const el of e) {
|
||||
if (el.end !== null) {
|
||||
const pid = el.project;
|
||||
if (!(pid in minutes)) {
|
||||
minutes[pid] = 0;
|
||||
}
|
||||
const end = new Date(el.end).getTime();
|
||||
const start = new Date(el.start).getTime();
|
||||
const elapsed = Math.round((end - start) / (1000 * 60));
|
||||
minutes[pid] = minutes[pid] + elapsed;
|
||||
for (const entry of entries.value) {
|
||||
if (
|
||||
entry.end === null ||
|
||||
entry.end.getTime() <= entry.start.getTime() ||
|
||||
entry.project === ""
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const project_id = entry.project;
|
||||
|
||||
if (!(project_id in hours)) {
|
||||
hours[project_id] = 0;
|
||||
}
|
||||
|
||||
const end = new Date(entry.end).getTime();
|
||||
const start = new Date(entry.start).getTime();
|
||||
const elapsed = Math.round(((end - start) / (1000 * 60 * 60)) * 100.0) / 100.0;
|
||||
hours[project_id] = hours[project_id] + elapsed;
|
||||
}
|
||||
|
||||
const result: { key: string; start: Date; end: Date }[] = [];
|
||||
let cumulative_sum = 0;
|
||||
for (const key in minutes) {
|
||||
const start = new Date(props.date.getTime());
|
||||
start.setHours(8, 0, 0);
|
||||
start.setMinutes(start.getMinutes() + cumulative_sum);
|
||||
cumulative_sum += minutes[key];
|
||||
const end = new Date(props.date.getTime());
|
||||
end.setHours(8, 0, 0);
|
||||
end.setMinutes(end.getMinutes() + cumulative_sum);
|
||||
result.push({ key, start, end });
|
||||
const out: { project_id: string; hours: number }[] = [];
|
||||
|
||||
for (const [project_id, total] of Object.entries(hours)) {
|
||||
out.push({ project_id, hours: total });
|
||||
}
|
||||
|
||||
return result;
|
||||
return out;
|
||||
});
|
||||
|
||||
const isEditorActive = computed(() => {
|
||||
|
|
@ -299,17 +296,12 @@ function projectTitleFormat(project: Project, titleLimit: number): string {
|
|||
<DataTable v-if="summaries.length > 0" :value="summaries">
|
||||
<Column header="Project">
|
||||
<template #body="slotProps">
|
||||
{{ projectTitleFormat(getProjectById(slotProps.data.key), 60) }}
|
||||
{{ projectTitleFormat(getProjectById(slotProps.data.project_id), 60) }}
|
||||
</template>
|
||||
</Column>
|
||||
<Column header="Start">
|
||||
<Column header="Hours">
|
||||
<template #body="slotProps">
|
||||
{{ getDateFmt(slotProps.data.start) }}
|
||||
</template>
|
||||
</Column>
|
||||
<Column header="End">
|
||||
<template #body="slotProps">
|
||||
{{ getDateFmt(slotProps.data.end) }}
|
||||
{{ slotProps.data.hours }}
|
||||
</template>
|
||||
</Column>
|
||||
</DataTable>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue