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 summaries = computed(() => {
|
||||||
const e = entries.value.filter((el) => {
|
const hours: { [key: string]: number } = {};
|
||||||
return el.end !== null && el.end.getTime() > el.start.getTime() && el.project !== "";
|
|
||||||
});
|
|
||||||
|
|
||||||
const minutes: { [key: string]: number } = {};
|
for (const entry of entries.value) {
|
||||||
|
if (
|
||||||
for (const el of e) {
|
entry.end === null ||
|
||||||
if (el.end !== null) {
|
entry.end.getTime() <= entry.start.getTime() ||
|
||||||
const pid = el.project;
|
entry.project === ""
|
||||||
if (!(pid in minutes)) {
|
) {
|
||||||
minutes[pid] = 0;
|
continue;
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const result: { key: string; start: Date; end: Date }[] = [];
|
const project_id = entry.project;
|
||||||
let cumulative_sum = 0;
|
|
||||||
for (const key in minutes) {
|
if (!(project_id in hours)) {
|
||||||
const start = new Date(props.date.getTime());
|
hours[project_id] = 0;
|
||||||
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 });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
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 out: { project_id: string; hours: number }[] = [];
|
||||||
|
|
||||||
|
for (const [project_id, total] of Object.entries(hours)) {
|
||||||
|
out.push({ project_id, hours: total });
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
});
|
});
|
||||||
|
|
||||||
const isEditorActive = computed(() => {
|
const isEditorActive = computed(() => {
|
||||||
|
|
@ -299,17 +296,12 @@ function projectTitleFormat(project: Project, titleLimit: number): string {
|
||||||
<DataTable v-if="summaries.length > 0" :value="summaries">
|
<DataTable v-if="summaries.length > 0" :value="summaries">
|
||||||
<Column header="Project">
|
<Column header="Project">
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
{{ projectTitleFormat(getProjectById(slotProps.data.key), 60) }}
|
{{ projectTitleFormat(getProjectById(slotProps.data.project_id), 60) }}
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column header="Start">
|
<Column header="Hours">
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
{{ getDateFmt(slotProps.data.start) }}
|
{{ slotProps.data.hours }}
|
||||||
</template>
|
|
||||||
</Column>
|
|
||||||
<Column header="End">
|
|
||||||
<template #body="slotProps">
|
|
||||||
{{ getDateFmt(slotProps.data.end) }}
|
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue