add subtraction of progress from before project's startTime.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -9,6 +9,7 @@ import type { LogResult } from "../models/log";
|
||||
amount: number
|
||||
target: number
|
||||
extras: number
|
||||
subs: number
|
||||
noTarget?: boolean
|
||||
}
|
||||
|
||||
@@ -26,7 +27,7 @@ import type { LogResult } from "../models/log";
|
||||
for (const task of project.tasks) {
|
||||
let entry = list.find(e => e.item.id === task.item.id);
|
||||
if (entry == null) {
|
||||
entry = {item: task.item, amount: 0, target: 0, extras: 0};
|
||||
entry = {item: task.item, amount: 0, target: 0, extras: 0, subs: 0};
|
||||
list.push(entry);
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ import type { LogResult } from "../models/log";
|
||||
if (log.secondaryItem != null) {
|
||||
let entry = list.find(e => e.item.id === log.secondaryItemId);
|
||||
if (entry == null) {
|
||||
entry = {item: log.secondaryItem, amount: 0, target: 0, extras: 0};
|
||||
entry = {item: log.secondaryItem, amount: 0, target: 0, extras: 0, subs: 0};
|
||||
list.push(entry);
|
||||
}
|
||||
|
||||
@@ -55,6 +56,17 @@ import type { LogResult } from "../models/log";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const {item, amount} of project.subtractions) {
|
||||
const entry = list.find(e => e.item.id === item.id);
|
||||
if (entry == null) {
|
||||
continue
|
||||
}
|
||||
|
||||
entry.subs += amount;
|
||||
entry.target -= amount;
|
||||
entry.amount -= amount;
|
||||
}
|
||||
}
|
||||
|
||||
for (const log of logs) {
|
||||
@@ -67,7 +79,7 @@ import type { LogResult } from "../models/log";
|
||||
if (item != null) {
|
||||
let entry = list.find(e => e.item.id === item.id);
|
||||
if (entry == null) {
|
||||
entry = {item, amount: 0, target: 0, extras: 0, noTarget: true};
|
||||
entry = {item, amount: 0, target: 0, extras: 0, noTarget: true, subs: 0};
|
||||
list.push(entry);
|
||||
}
|
||||
|
||||
@@ -86,7 +98,7 @@ import type { LogResult } from "../models/log";
|
||||
} else {
|
||||
return b.target - a.target;
|
||||
}
|
||||
}).filter(l => l.extras > 0 || (l.target > 0 || l.noTarget));
|
||||
}).filter(e => e.extras > 0 || (e.target > 0 || e.subs > 0 || e.noTarget));
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -120,6 +132,11 @@ import type { LogResult } from "../models/log";
|
||||
×{entry.extras}
|
||||
</div>
|
||||
{/if}
|
||||
{#if entry.subs > 0}
|
||||
<div class="subs" title="These items are from before the project's start time.">
|
||||
–{entry.subs}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
@@ -166,4 +183,7 @@ import type { LogResult } from "../models/log";
|
||||
div.ItemProgress div.entry .extras {
|
||||
color: #484;
|
||||
}
|
||||
div.ItemProgress div.entry .subs {
|
||||
color: #852a24;
|
||||
}
|
||||
</style>
|
||||
@@ -23,6 +23,11 @@
|
||||
|
||||
progressTarget = Math.max((project.tasks||[]).map(t => t.itemAmount * (t.item.groupWeight || 1)).reduce((n,m) => n+m, 0), 1);
|
||||
|
||||
for (const {item, amount} of (project.subtractions||[])) {
|
||||
progressAmount -= item.groupWeight * amount;
|
||||
progressTarget -= item.groupWeight * amount;
|
||||
}
|
||||
|
||||
progressAmount = Math.max(progressAmount - project.subtractAmount, 0);
|
||||
progressTarget = Math.max(progressTarget - project.subtractAmount, 0);
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { ProjectSubtraction } from "../models/project";
|
||||
|
||||
import type { TaskResult } from "../models/task";
|
||||
import Progress from "./Progress.svelte";
|
||||
|
||||
@@ -6,6 +8,7 @@
|
||||
tasks?: TaskResult[]
|
||||
statusTag?: string
|
||||
subtractAmount?: number,
|
||||
subtractions?: ProjectSubtraction[]
|
||||
}
|
||||
|
||||
export let project: ProjectLike;
|
||||
@@ -20,6 +23,11 @@
|
||||
).reduce((n,m) => n+m, 0);
|
||||
progressTarget = Math.max((project.tasks||[]).map(t => t.itemAmount * (t.item.groupWeight || 1)).reduce((n,m) => n+m, 0), 1);
|
||||
|
||||
for (const {item, amount} of (project.subtractions||[])) {
|
||||
progressAmount -= item.groupWeight * amount;
|
||||
progressTarget -= item.groupWeight * amount;
|
||||
}
|
||||
|
||||
progressAmount = Math.max(progressAmount - (project.subtractAmount||0), 0);
|
||||
progressTarget = Math.max(progressTarget - (project.subtractAmount||0), 0);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { IconName } from "../external/icons";
|
||||
import type Item from "./item";
|
||||
import type { TaskResult } from "./task";
|
||||
|
||||
export default interface Project {
|
||||
@@ -19,6 +20,12 @@ export default interface Project {
|
||||
|
||||
export interface ProjectResult extends Project {
|
||||
tasks: TaskResult[]
|
||||
subtractions: ProjectSubtraction[]
|
||||
}
|
||||
|
||||
export interface ProjectSubtraction {
|
||||
item: Item
|
||||
amount: number
|
||||
}
|
||||
|
||||
export interface ProjectFilter {
|
||||
|
||||
Reference in New Issue
Block a user