add project to logs, project composition mode to goals and fix unweighted counts for other composition modes.
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-05-01 12:28:45 +02:00
parent 897f4aa358
commit 589f7a9132
10 changed files with 104 additions and 15 deletions
@@ -29,8 +29,11 @@
}
interface EntryCommonSub {
id?: string
name: string
icon: IconName
project?: EntryCommonSub
tags?: string[]
}
export let entry: EntryCommon = null;
@@ -64,6 +67,10 @@
<a href={`/questlog#${actualParent.id}`}>{actualParent.name}</a>
</div>
{/if}
{:else if (entry.task && entry.task.project != null)}
<div class="actual-parent">
<a href={`/questlog#${entry.task.project.id}`}>{entry.task.project.name}</a>
</div>
{/if}
<div class="name">{displayName}</div>
<div class="separator"></div>
+25 -1
View File
@@ -9,11 +9,24 @@
}
export let logs: LogResult[] = [];
export let unweighted: boolean = false;
export let mode: GoalCompositionMode = "item";
export let ignoreZeroWeight: boolean = false;
let list: CompositionItem[] = [];
function calculateAmount(log: LogResult, unweighted: boolean) {
let amount = 0;
if (log.itemCounted) {
amount += log.itemAmount * (unweighted ? 1 : log.item.groupWeight);
}
if (log.secondaryItemCounted) {
amount += log.secondaryItemAmount * (unweighted ? 1 : log.secondaryItem.groupWeight);
}
return amount;
}
$: {
const map: {[k: string]: CompositionItem} = {}
@@ -41,11 +54,22 @@
}
}
}
} else if (mode === "project") {
for (const log of logs) {
const project = log.task.project;
const amount = calculateAmount(log, unweighted);
if (!map[project.id]) {
map[project.id] = {name: project.name, amount, link: `/questlog#${project.id}`};
} else {
map[project.id].amount += amount;
}
}
} else {
for (const log of logs) {
const task = log.task;
const amount = log.secondaryItem ? log.secondaryItemAmount + log.itemAmount : log.itemAmount;
const amount = calculateAmount(log, unweighted);
if (!map[task.id]) {
map[task.id] = {name: task.name, amount, link: `/questlog#${task.projectId}`};
+1
View File
@@ -132,6 +132,7 @@ import DateRangeSelect from "../components/DateRangeSelect.svelte";
<select name="compositionMode" bind:value={compositionMode} disabled={deletion}>
<option value="item" selected={"item" === compositionMode}>Item</option>
<option value="task" selected={"task" === compositionMode}>Task</option>
<option value="project" selected={"project" === compositionMode}>Project</option>
</select>
<DateRangeSelect disabled={deletion} bind:fromValue={startTime} bind:toValue={endTime} />
<label for="taskFilter">Task Filter (Optional)</label>
+1 -1
View File
@@ -2,7 +2,7 @@ import type Group from "./group";
import type Item from "./item";
import type { LogResult } from "./log";
export type GoalCompositionMode = "task" | "item"
export type GoalCompositionMode = "task" | "project" | "item"
export default interface Goal {
id: string
+2 -2
View File
@@ -1,5 +1,5 @@
import type Item from "./item";
import type Task from "./task";
import type { TaskWithProject } from "./task";
export default interface Log {
id: string
@@ -18,7 +18,7 @@ export interface LogFilter {
}
export interface LogResult extends Log {
task: Task
task: TaskWithProject
item: Item
secondaryItem?: Item
itemCounted?: boolean
+5
View File
@@ -16,6 +16,11 @@ export default interface Task {
endTime?: string
statusTag?: string
}
export interface TaskWithProject extends Task {
project?: Project
}
export interface TaskResult extends Task {
item: Item
logs: Log[]