Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b73c83b3b | ||
|
|
3a1142a965 | ||
|
|
3737a80c46 | ||
|
|
0d2e027816 | ||
|
|
cac4ac0bf6 | ||
|
|
f5dee09e40 | ||
|
|
53be464d7e | ||
|
|
b381e2cbed | ||
|
|
d7c1fbb21c | ||
|
|
d4141f5eb3 | ||
|
|
1232721921 | ||
|
|
a70bb4bb23 | ||
|
|
0ba65038e9 | ||
|
|
6c3fdad79c | ||
|
|
e307ed6021 | ||
|
|
e4c41e1d47 | ||
|
|
ae47f1a0e5 | ||
|
|
b9ffe256e9 |
+11
-7
@@ -31,13 +31,14 @@ func (project *Project) Update(update models.ProjectUpdate) {
|
||||
}
|
||||
|
||||
type Requirement struct {
|
||||
ID int `json:"id"`
|
||||
ScopeID int `json:"scopeId"`
|
||||
ProjectID int `json:"projectId"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
IsCoarse bool `json:"isCoarse"`
|
||||
Status models.Status `json:"status"`
|
||||
ID int `json:"id"`
|
||||
ScopeID int `json:"scopeId"`
|
||||
ProjectID int `json:"projectId"`
|
||||
AggregateRequired int `json:"aggregateRequired"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
IsCoarse bool `json:"isCoarse"`
|
||||
Status models.Status `json:"status"`
|
||||
}
|
||||
|
||||
func (requirement *Requirement) Update(update models.RequirementUpdate) {
|
||||
@@ -53,6 +54,9 @@ func (requirement *Requirement) Update(update models.RequirementUpdate) {
|
||||
if update.IsCoarse != nil {
|
||||
requirement.IsCoarse = *update.IsCoarse
|
||||
}
|
||||
if update.AggregateRequired != nil {
|
||||
requirement.AggregateRequired = *update.AggregateRequired
|
||||
}
|
||||
}
|
||||
|
||||
type RequirementStat struct {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts">
|
||||
import shortestDecimal from "$lib/utils/numbers";
|
||||
|
||||
import { significantDecimals } from "$lib/utils/numbers";
|
||||
import PlusMinus from "../layout/PlusMinus.svelte"
|
||||
|
||||
export let label: string
|
||||
@@ -8,25 +7,17 @@ import shortestDecimal from "$lib/utils/numbers";
|
||||
export let target: number = null
|
||||
export let right: boolean = false;
|
||||
export let dark: boolean = false;
|
||||
export let weighted: boolean = false;
|
||||
|
||||
let valueRounded: number;
|
||||
let targetRounded: number;
|
||||
let valueString: string;
|
||||
let targetString: string;
|
||||
$: {
|
||||
valueRounded = Math.round(value * 1000) / 1000;
|
||||
|
||||
if (target != null) {
|
||||
targetRounded = Math.round(target * 1000) / 1000;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
$: valueString = !weighted ? Math.round(value).toFixed() : significantDecimals(value);
|
||||
|
||||
</script>
|
||||
|
||||
<span class:dark class="value">{shortestDecimal(valueRounded)}×</span>
|
||||
<div class="amount" class:right>
|
||||
<span class:dark class="value">{valueString}×</span>
|
||||
{ #if target != null && targetRounded != valueRounded }
|
||||
<span class="target">(<PlusMinus offset={valueRounded - targetRounded} />)</span>
|
||||
<span class="label">{label}</span>
|
||||
{ #if target != null && target != value }
|
||||
<span class="target">(<PlusMinus integersOnly={!weighted} offset={value - target} />)</span>
|
||||
{ /if }
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { significantDecimals } from "$lib/utils/numbers";
|
||||
|
||||
export let target = 1;
|
||||
export let count = 0;
|
||||
export let green = false;
|
||||
export let alwaysSmooth = false;
|
||||
export let percentageOnly = false;
|
||||
export let weighted = false;
|
||||
export let compact = false;
|
||||
|
||||
export let fullwidth = false;
|
||||
@@ -38,7 +41,11 @@
|
||||
{#if percentageOnly}
|
||||
<span class="ackreq">({((count / target) * 100).toFixed(0)}%)</span>
|
||||
{:else}
|
||||
<span class="ackreq">({Math.floor(count)} / {Math.ceil(target)})</span>
|
||||
{#if weighted}
|
||||
<span class="ackreq">({significantDecimals(count)} / {significantDecimals(target)})</span>
|
||||
{:else}
|
||||
<span class="ackreq">({Math.round(count)} / {Math.round(target)})</span>
|
||||
{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -15,7 +15,14 @@
|
||||
|
||||
div.markdown :global(p) {
|
||||
padding: 0;
|
||||
margin: 0.25em 0;
|
||||
margin: 0.5em 0;
|
||||
|
||||
&:first-of-type {
|
||||
margin-top: 0.25em;
|
||||
}
|
||||
&:last-of-type {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
div.markdown :global(code) {
|
||||
|
||||
@@ -94,6 +94,10 @@
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
@media screen and (max-width: 749px) {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
div.title {
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
padding-left: 0
|
||||
flex: 1
|
||||
|
||||
div.modal-body:first-of-type
|
||||
padding-left: 1em
|
||||
@media screen and (max-width: 749px)
|
||||
padding-left: 1em
|
||||
padding: 0 1em
|
||||
|
||||
&:first-of-type
|
||||
padding-left: 1em
|
||||
</style>
|
||||
@@ -67,6 +67,11 @@
|
||||
// Mark it non-segmented if the target is too high. This prevents a clunky progress bar,
|
||||
// or a browser freeze if you set the target very high.
|
||||
nonSegmented = alwaysSmooth || (target >= 60);
|
||||
|
||||
if (!nonSegmented) {
|
||||
ons = Math.round(ons);
|
||||
offs = Math.round(offs);
|
||||
}
|
||||
} else {
|
||||
offClass = "none";
|
||||
nonSegmented = alwaysSmooth;
|
||||
|
||||
@@ -16,6 +16,6 @@
|
||||
3: "spinner",
|
||||
4: "check",
|
||||
5: "times",
|
||||
6: "times",
|
||||
6: "trash",
|
||||
}
|
||||
</script>
|
||||
@@ -49,7 +49,7 @@
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await sl3(fetch).listItems($scope.id, filter, true)
|
||||
const res = await sl3(fetch).listItems($scope.id, filter, true, {});
|
||||
itemsWritable.set(res.items);
|
||||
groupsWritable.set(res.groups);
|
||||
} catch(_) {}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<script lang="ts">
|
||||
import type { Requirement } from "$lib/models/project";
|
||||
|
||||
export let value: number;
|
||||
export let requirements: Requirement[];
|
||||
export let disabled: boolean = false;
|
||||
</script>
|
||||
|
||||
<select disabled={disabled} bind:value={value}>
|
||||
{#each requirements as req (req.id)}
|
||||
<option value={req.id}>{req.name} ({req.statusName})</option>
|
||||
{/each}
|
||||
</select>
|
||||
@@ -57,8 +57,6 @@
|
||||
required: requiredMap[s.id],
|
||||
acquired: acquiredMap[s.id],
|
||||
}));
|
||||
|
||||
$: console.log(value);
|
||||
</script>
|
||||
|
||||
<div class="stat-input">
|
||||
|
||||
@@ -1,34 +1,68 @@
|
||||
<script lang="ts">
|
||||
import Status from "$lib/models/status";
|
||||
|
||||
export let status: Status;
|
||||
<script lang="ts" context="module">
|
||||
const STATUS_ENTRIES: [Status, IconName][] = Object.entries(STATUS_ICONS).map(e => [parseInt(e[0]) as Status, e[1]])
|
||||
</script>
|
||||
|
||||
<select class={`sc-${status}`} bind:value={status}>
|
||||
<option class="sc-0" value={Status.Blocked}>Blocked</option>
|
||||
<option class="sc-1" value={Status.Available}>Available</option>
|
||||
<option class="sc-2" value={Status.Background}>Background</option>
|
||||
<option class="sc-3" value={Status.Active}>Active</option>
|
||||
<option class="sc-4" value={Status.Completed}>Completed</option>
|
||||
<option class="sc-5" value={Status.Failed}>Failed</option>
|
||||
<option class="sc-6" value={Status.Dropped}>Dropped</option>
|
||||
</select>
|
||||
<script lang="ts">
|
||||
import type Status from "$lib/models/status";
|
||||
import { STATUS_NAMES } from "$lib/models/status";
|
||||
import { STATUS_ICONS } from "../common/StatusIcon.svelte";
|
||||
import Icon, { type IconName } from "../layout/Icon.svelte";
|
||||
|
||||
export let status: Status;
|
||||
|
||||
console.log(STATUS_ENTRIES, status)
|
||||
</script>
|
||||
|
||||
<div class="status-select">
|
||||
{#each STATUS_ENTRIES as [id, iconName] (id)}
|
||||
<div on:click={() => {status = id}} class="option sc-{id}" class:selected={status === id}>
|
||||
<Icon name={iconName} />
|
||||
</div>
|
||||
{/each}
|
||||
<div class="status-name">{STATUS_NAMES[status]}</div>
|
||||
</div>
|
||||
|
||||
<style lang="sass">
|
||||
@import "../../css/colors"
|
||||
|
||||
.sc-0
|
||||
color: $sc-0 !important
|
||||
.sc-1
|
||||
color: $sc-1 !important
|
||||
.sc-2
|
||||
color: $sc-2 !important
|
||||
.sc-3
|
||||
color: $sc-3 !important
|
||||
.sc-4
|
||||
color: $sc-4 !important
|
||||
.sc-5
|
||||
color: $sc-5 !important
|
||||
.sc-6
|
||||
color: $sc-6 !important
|
||||
div.status-select
|
||||
background-color: $color-entryhalf
|
||||
display: flex
|
||||
flex-direction: row
|
||||
margin-bottom: 0.8em
|
||||
margin-top: 0.2em
|
||||
|
||||
div.status-name
|
||||
margin-left: auto
|
||||
margin-top: 0.275em
|
||||
margin-right: 1ch
|
||||
color: $color-entry7
|
||||
|
||||
div.option
|
||||
padding: 0.2em 0.5ch
|
||||
font-size: 1.175em
|
||||
color: $color-entry2
|
||||
cursor: pointer
|
||||
line-height: 1em
|
||||
|
||||
&.sc-4, &.sc-2
|
||||
border-left: 1px solid $color-entry1
|
||||
|
||||
&:hover
|
||||
color: $color-entry3
|
||||
|
||||
&.selected.sc-0
|
||||
color: $sc-0 !important
|
||||
&.selected.sc-1
|
||||
color: $sc-1 !important
|
||||
&.selected.sc-2
|
||||
color: $sc-2 !important
|
||||
&.selected.sc-3
|
||||
color: $sc-3 !important
|
||||
&.selected.sc-4
|
||||
color: $sc-4 !important
|
||||
&.selected.sc-5
|
||||
color: $sc-5 !important
|
||||
&.selected.sc-6
|
||||
color: $sc-6 !important
|
||||
</style>
|
||||
@@ -1,10 +1,21 @@
|
||||
<script lang="ts">
|
||||
import type { TimeInterval } from "$lib/models/common";
|
||||
import parseInterval, { datesOf } from "$lib/utils/timeinterval";
|
||||
import { getItemListContext } from "../contexts/ItemListContext.svelte";
|
||||
import { getTimeContext } from "../contexts/TimeContext.svelte";
|
||||
import HistoryGroupSection from "./HistoryGroupSection.svelte";
|
||||
|
||||
export let intervalString: string;
|
||||
|
||||
const {groups, items} = getItemListContext();
|
||||
const {now} = getTimeContext();
|
||||
|
||||
let interval: TimeInterval<string>
|
||||
$: interval = datesOf(parseInterval(intervalString, $now));
|
||||
</script>
|
||||
|
||||
{#each $groups as group (group.label)}
|
||||
<HistoryGroupSection group={group} items={$items} />
|
||||
{#if (group.label >= interval.min && group.label <= interval.max)}
|
||||
<HistoryGroupSection group={group} items={$items} />
|
||||
{/if}
|
||||
{/each}
|
||||
@@ -2,14 +2,19 @@
|
||||
import type Item from "$lib/models/item";
|
||||
import type { ItemGroup } from "$lib/models/item";
|
||||
import Section from "../layout/Section.svelte";
|
||||
import AggregateAmountRow from "../project/AggregateAmountRow.svelte";
|
||||
import ItemSubSection from "../project/ItemSubSection.svelte";
|
||||
|
||||
export let group: ItemGroup;
|
||||
export let items: Item[];
|
||||
|
||||
let acquiredItems: Item[];
|
||||
$: acquiredItems = group.list.filter(ref => ref.event === "acquired").map(ref => items[ref.idx]);
|
||||
</script>
|
||||
|
||||
<Section title={group.label}>
|
||||
{#each group.list as ref (ref.idx)}
|
||||
<ItemSubSection item={items[ref.idx]} event={ref.event} />
|
||||
{/each}
|
||||
<AggregateAmountRow items={acquiredItems} />
|
||||
</Section>
|
||||
@@ -1,12 +1,18 @@
|
||||
<script lang="ts">
|
||||
import shortestDecimal from "$lib/utils/numbers";
|
||||
|
||||
import { significantDecimals } from "$lib/utils/numbers";
|
||||
|
||||
export let offset: number;
|
||||
export let integersOnly: boolean = false;
|
||||
|
||||
let value: string;
|
||||
let negative: boolean
|
||||
$: value = (offset > 0) ? `+${shortestDecimal(offset)}` : shortestDecimal(offset);
|
||||
let negative: boolean;
|
||||
$: {
|
||||
if (integersOnly) {
|
||||
value = (offset > 0) ? `+${Math.round(offset).toFixed()}` : Math.round(offset).toFixed();
|
||||
} else {
|
||||
value = (offset > 0) ? `+${significantDecimals(offset)}` : significantDecimals(offset);
|
||||
}
|
||||
}
|
||||
$: negative = offset < 0
|
||||
</script>
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<script lang="ts">
|
||||
import type Item from "$lib/models/item";
|
||||
import Amount from "../common/Amount.svelte";
|
||||
import AmountRow from "../common/AmountRow.svelte";
|
||||
import { getScopeContext } from "../contexts/ScopeContext.svelte";
|
||||
|
||||
export let items: Item[];
|
||||
export let totalAcquired: number = null;
|
||||
export let aggregateRequired: number = null;
|
||||
|
||||
const {scope} = getScopeContext();
|
||||
|
||||
let amounts: {name: string, amount: number}[] = [];
|
||||
let total;
|
||||
let required;
|
||||
|
||||
$: {
|
||||
const statMap: Record<number, number> = {};
|
||||
|
||||
total = 0;
|
||||
required = 0;
|
||||
|
||||
for (const item of items) {
|
||||
for (const stat of item.stats) {
|
||||
statMap[stat.id] = (statMap[stat.id] || 0) + stat.acquired;
|
||||
required += stat.required * stat.weight;
|
||||
total += stat.acquired * stat.weight;
|
||||
}
|
||||
}
|
||||
|
||||
if (totalAcquired != null) {
|
||||
total = totalAcquired;
|
||||
}
|
||||
if (aggregateRequired != null) {
|
||||
required = aggregateRequired;
|
||||
}
|
||||
|
||||
amounts = [];
|
||||
for (const stat of $scope.stats) {
|
||||
if (!!statMap[stat.id]) {
|
||||
amounts.push({name: stat.name, amount: statMap[stat.id]});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<AmountRow>
|
||||
{#each amounts as {name, amount} (name)}
|
||||
<Amount label={name} value={amount} />
|
||||
{/each}
|
||||
<Amount weighted right label="" dark value={total} target={required} />
|
||||
</AmountRow>
|
||||
@@ -11,6 +11,7 @@
|
||||
import Icon from "../layout/Icon.svelte";
|
||||
import { formatTime } from "$lib/utils/date";
|
||||
import RequirementReference from "./RequirementReference.svelte";
|
||||
import ItemTimeInfo from "./ItemTimeInfo.svelte";
|
||||
|
||||
export let item: Item;
|
||||
export let event: "created" | "scheduled" | "acquired" | "none" = "none";
|
||||
@@ -57,6 +58,8 @@
|
||||
</OptionsRow>
|
||||
{#if item.project != null}
|
||||
<RequirementReference project={item.project} requirement={item.requirement} scopeId={item.scopeId} />
|
||||
{:else}
|
||||
<ItemTimeInfo item={item} />
|
||||
{/if}
|
||||
{#if !compact}
|
||||
<Markdown source={item.description} />
|
||||
@@ -70,7 +73,7 @@
|
||||
{/if}
|
||||
{/each}
|
||||
{#if item.weightedRequired}
|
||||
<Amount dark right label="" value={item.weightedAcquired} target={item.weightedRequired} />
|
||||
<Amount weighted dark right label="" value={item.weightedAcquired} target={item.weightedRequired} />
|
||||
{/if}
|
||||
{:else}
|
||||
{#each item.stats as stat (stat.id)}
|
||||
@@ -79,7 +82,7 @@
|
||||
{/if}
|
||||
{/each}
|
||||
{#if item.weightedRequired}
|
||||
<Amount dark right label="" value={item.weightedRequired} />
|
||||
<Amount weighted dark right label="" value={item.weightedRequired} />
|
||||
{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<script lang="ts">
|
||||
import type Item from "$lib/models/item";
|
||||
import { formatPrettyTime } from "$lib/utils/date";
|
||||
import { getTimeContext } from "../contexts/TimeContext.svelte";
|
||||
|
||||
export let item: Item
|
||||
|
||||
const {now} = getTimeContext();
|
||||
|
||||
let action = "create";
|
||||
let colorClass = "";
|
||||
let timeStr = "";
|
||||
|
||||
$: {
|
||||
const ct = new Date(item.createdTime);
|
||||
let t = ct;
|
||||
|
||||
if (item.acquiredTime != null) {
|
||||
const at = new Date(item.acquiredTime);
|
||||
t = at;
|
||||
|
||||
if (Math.abs(at.getTime() - ct.getTime()) < 300000) {
|
||||
action = "Created/Acquired"
|
||||
} else {
|
||||
action = "Acquired"
|
||||
}
|
||||
colorClass = "acquired"
|
||||
} else if (item.scheduledDate != null) {
|
||||
t = new Date(item.scheduledDate);
|
||||
action = "Scheduled for"
|
||||
colorClass = "scheduled"
|
||||
} else {
|
||||
action = "Created"
|
||||
colorClass = "created"
|
||||
}
|
||||
|
||||
timeStr = formatPrettyTime(t, $now);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="item-time {colorClass}">
|
||||
<span class="action">{action}</span>
|
||||
<span class="timeStr">{timeStr}</span>
|
||||
</div>
|
||||
|
||||
<style lang="sass">
|
||||
@import "../../css/colors"
|
||||
|
||||
div.item-time
|
||||
font-size: 0.8em
|
||||
|
||||
color: $color-entry3
|
||||
|
||||
&.created
|
||||
color: $sc-1-dim
|
||||
&.acquired
|
||||
color: $sc-4-dim
|
||||
&.scheduled
|
||||
color: $sc-0
|
||||
|
||||
> span.timeStr
|
||||
font-weight: 800
|
||||
|
||||
</style>
|
||||
@@ -11,6 +11,8 @@
|
||||
import ItemEntry from "./ItemSubSection.svelte";
|
||||
import Icon from "../layout/Icon.svelte";
|
||||
import { projectPrettyId } from "$lib/utils/prettyIds";
|
||||
import AmountRow from "../common/AmountRow.svelte";
|
||||
import AggregateAmountRow from "./AggregateAmountRow.svelte";
|
||||
|
||||
export let requirement: Requirement;
|
||||
</script>
|
||||
@@ -35,4 +37,7 @@
|
||||
{#each requirement.items as item (item.id)}
|
||||
<ItemEntry item={item} />
|
||||
{/each}
|
||||
{#if requirement.aggregateRequired > 0}
|
||||
<AggregateAmountRow items={requirement.items} totalAcquired={requirement.totalAcquired} aggregateRequired={requirement.aggregateRequired} />
|
||||
{/if}
|
||||
</Section>
|
||||
@@ -24,7 +24,7 @@
|
||||
{#if sprint.kind === SprintKind.Items}
|
||||
<LabeledProgress timeRange={timeRange} green name={sprint.aggregateName || "Items"} count={sprint.itemsAcquired} target={sprint.itemsRequired} />
|
||||
{:else}
|
||||
<LabeledProgress timeRange={timeRange} name={sprint.aggregateName} count={sprint.aggregateAcquired} target={sprint.aggregateRequired} />
|
||||
<LabeledProgress timeRange={timeRange} name={sprint.aggregateName} count={sprint.aggregateAcquired} target={sprint.aggregateRequired} weighted={!sprint.isUnweighted} />
|
||||
{/if}
|
||||
{#if !sprint.isCoarse}
|
||||
<LabeledProgressRow>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<Markdown source={stat.description} />
|
||||
{#if stat.weight !== 1}
|
||||
<AmountRow>
|
||||
<Amount label="Weight" value={stat.weight} />
|
||||
<Amount weighted label="Weight" value={stat.weight} />
|
||||
</AmountRow>
|
||||
{/if}
|
||||
</SubSection>
|
||||
@@ -25,9 +25,11 @@ $opacity-entry6: 0.80
|
||||
$sc-0: #78c9ff
|
||||
$sc-0-dark: #34424b
|
||||
$sc-1: #e7e55e
|
||||
$sc-1-dim: #a3a352
|
||||
$sc-2: #e7a75e
|
||||
$sc-3: $color-entry12
|
||||
$sc-4: #78ff78
|
||||
$sc-4-dim: #549454
|
||||
$sc-4-dark: #2f422f
|
||||
$sc-5: #c94339
|
||||
$sc-6: #e75ed0
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
import { getScopeListContext } from "$lib/components/contexts/ScopeListContext.svelte";
|
||||
import { getSprintListContext } from "$lib/components/contexts/SprintListContext.svelte";
|
||||
import AcquiredTimeInput from "$lib/components/controls/AcquiredTimeInput.svelte";
|
||||
import RequirementSelect from "$lib/components/controls/RequirementSelect.svelte";
|
||||
import StatInput from "$lib/components/controls/StatInput.svelte";
|
||||
import type Item from "$lib/models/item";
|
||||
import type { ItemInput } from "$lib/models/item";
|
||||
@@ -107,7 +108,7 @@
|
||||
|
||||
op = "Edit"
|
||||
openedDate = new Date();
|
||||
requirementName = req?.name;
|
||||
requirementName = current.requirement?.name;
|
||||
show = true;
|
||||
}
|
||||
|
||||
@@ -185,7 +186,11 @@
|
||||
<ModalBody>
|
||||
{#if requirementName != null}
|
||||
<label for="req">Project Requirement</label>
|
||||
<input disabled name="req" type="text" value={requirementName} />
|
||||
{#if $project.id != null}
|
||||
<RequirementSelect disabled={op === "Create"} requirements={$project.requirements} bind:value={item.requirementId} />
|
||||
{:else}
|
||||
<input disabled name="req" type="text" value={requirementName} />
|
||||
{/if}
|
||||
{/if}
|
||||
<label for="stats">Stats</label>
|
||||
<StatInput
|
||||
|
||||
@@ -21,6 +21,7 @@ import { statDiff } from "$lib/utils/stat";
|
||||
let projectId: number
|
||||
let requirementId: number
|
||||
let oldStats: RequirementInput["stats"]
|
||||
let showAggregateRequired: boolean
|
||||
|
||||
let error: string
|
||||
let loading: boolean
|
||||
@@ -44,6 +45,8 @@ import { statDiff } from "$lib/utils/stat";
|
||||
show = false;
|
||||
}
|
||||
|
||||
$: showAggregateRequired = requirement?.stats?.find(s => s.required > 0) == null;
|
||||
|
||||
function initCreate(project: ProjectEntry) {
|
||||
requirement = {
|
||||
name: "",
|
||||
@@ -51,6 +54,7 @@ import { statDiff } from "$lib/utils/stat";
|
||||
stats: [],
|
||||
status: Status.Available,
|
||||
isCoarse: false,
|
||||
aggregateRequired: 0,
|
||||
}
|
||||
|
||||
projectId = project.id;
|
||||
@@ -64,6 +68,7 @@ import { statDiff } from "$lib/utils/stat";
|
||||
status: current.status,
|
||||
stats: current.stats.map(s => ({acquired: s.acquired, required: s.required, statId: s.id})),
|
||||
isCoarse: current.isCoarse,
|
||||
aggregateRequired: current.aggregateRequired,
|
||||
}
|
||||
|
||||
oldStats = [...requirement.stats];
|
||||
@@ -76,6 +81,10 @@ import { statDiff } from "$lib/utils/stat";
|
||||
error = null;
|
||||
loading = true;
|
||||
|
||||
if (requirement.stats.find(s => s.required > 0)) {
|
||||
requirement.aggregateRequired = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
switch (op) {
|
||||
case "Create":
|
||||
@@ -115,6 +124,10 @@ import { statDiff } from "$lib/utils/stat";
|
||||
<input name="name" type="text" bind:value={requirement.name} />
|
||||
<label for="description">Description</label>
|
||||
<textarea name="description" bind:value={requirement.description} />
|
||||
{#if showAggregateRequired}
|
||||
<label for="aggregateRequired">Aggregate Required (Zero for old behavior)</label>
|
||||
<input name="aggregateRequired" type="number" bind:value={requirement.aggregateRequired} />
|
||||
{/if}
|
||||
</ModalBody>
|
||||
<ModalBody>
|
||||
<label for="stats">Status</label>
|
||||
|
||||
@@ -38,6 +38,7 @@ export interface Requirement {
|
||||
totalRequired: number
|
||||
totalPlanned: number
|
||||
isCoarse: boolean
|
||||
aggregateRequired: number
|
||||
stats: StatProgressWithPlanned[]
|
||||
items: Item[]
|
||||
}
|
||||
@@ -47,5 +48,6 @@ export interface RequirementInput {
|
||||
description: string
|
||||
status: Status
|
||||
isCoarse: boolean
|
||||
aggregateRequired: number
|
||||
stats: StatValueInput[]
|
||||
}
|
||||
@@ -8,4 +8,14 @@ enum Status {
|
||||
Dropped,
|
||||
};
|
||||
|
||||
export const STATUS_NAMES: Record<Status, string> = {
|
||||
[Status.Blocked]: "Blocked",
|
||||
[Status.Available]: "Available",
|
||||
[Status.Background]: "Background",
|
||||
[Status.Active]: "Active",
|
||||
[Status.Completed]: "Completed",
|
||||
[Status.Failed]: "Failed",
|
||||
[Status.Dropped]: "Dropped",
|
||||
}
|
||||
|
||||
export default Status;
|
||||
@@ -114,7 +114,7 @@ export function endOfDay(now: Date): Date {
|
||||
}
|
||||
|
||||
export function monthName(date: Date): string {
|
||||
return monthNames[date.getMonth()]
|
||||
return monthNames[date.getMonth() - 1]
|
||||
}
|
||||
|
||||
export function addDays(date: Date, days: number): Date {
|
||||
@@ -133,4 +133,24 @@ export function addYears(date: Date, years: number): Date {
|
||||
const newDate = new Date(date.getTime());
|
||||
newDate.setFullYear(newDate.getFullYear() + years);
|
||||
return newDate;
|
||||
}
|
||||
|
||||
export function formatPrettyTime(date: Date, now: Date) {
|
||||
const d = startOfDay(date);
|
||||
const n = startOfDay(now);
|
||||
|
||||
const diff = (d.getTime() - n.getTime()) / (86400000);
|
||||
|
||||
const hhmm = `${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
||||
if (diff === 0) {
|
||||
return `today at ${hhmm}`;
|
||||
} else if (diff === 1) {
|
||||
return `tomorrow at ${hhmm}`;
|
||||
} else if (diff === -1) {
|
||||
return `yesterday at ${hhmm}`;
|
||||
} else if (diff > -3 && diff < 6) {
|
||||
return `${weekDay[date.getDay()]} at ${hhmm}`;
|
||||
} else {
|
||||
return `${monthName(date)} ${date.getDate()} at ${hhmm}`;
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,20 @@ export default function shortestDecimal(n: number) {
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
export function significantDecimals(n: number): string {
|
||||
if (n >= 99.95) {
|
||||
return n.toFixed();
|
||||
} else if (n >= 9.95) {
|
||||
return n.toFixed(1);
|
||||
} else if (n >= 0.01) {
|
||||
return n.toFixed(2);
|
||||
} else if (n >= 0.001) {
|
||||
return n.toFixed(3);
|
||||
} else if (n >= 0) {
|
||||
return n.toFixed(2);
|
||||
} else {
|
||||
return "-" + significantDecimals(-n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import type { Load } from "@sveltejs/kit/types/internal";
|
||||
|
||||
import { sl3 } from "$lib/clients/sl3";
|
||||
import parseInterval, { datesOf, intervalLabel } from "$lib/utils/timeinterval";
|
||||
import parseInterval, { datesOf } from "$lib/utils/timeinterval";
|
||||
import type Item from "$lib/models/item";
|
||||
import type { ItemFilter, ItemGroup } from "$lib/models/item";
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
<ToggleIcon inverse name="calendar" bind:value={$session.groupOptions.hideScheduled} on:click={triggerReload} />
|
||||
{/if}
|
||||
</HistorySelector>
|
||||
<HistoryGroupList />
|
||||
<HistoryGroupList intervalString={intervalString} />
|
||||
</Main>
|
||||
|
||||
<ItemCreateModal />
|
||||
|
||||
@@ -9,6 +9,7 @@ require (
|
||||
github.com/awslabs/aws-lambda-go-api-proxy v0.13.3
|
||||
github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1
|
||||
github.com/gin-gonic/gin v1.7.7
|
||||
github.com/go-playground/assert/v2 v2.0.1
|
||||
github.com/go-sql-driver/mysql v1.6.0
|
||||
github.com/lestrrat-go/jwx v1.2.25
|
||||
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29
|
||||
|
||||
+5
-4
@@ -8,8 +8,9 @@ type ProjectUpdate struct {
|
||||
}
|
||||
|
||||
type RequirementUpdate struct {
|
||||
Name *string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
Status *Status `json:"status"`
|
||||
IsCoarse *bool `json:"isCoarse"`
|
||||
Name *string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
Status *Status `json:"status"`
|
||||
IsCoarse *bool `json:"isCoarse"`
|
||||
AggregateRequired *int `json:"aggregateRequired"`
|
||||
}
|
||||
|
||||
@@ -41,13 +41,14 @@ type Project struct {
|
||||
}
|
||||
|
||||
type ProjectRequirement struct {
|
||||
ID int
|
||||
ScopeID int
|
||||
ProjectID int
|
||||
Name string
|
||||
Status int
|
||||
Description string
|
||||
IsCoarse bool
|
||||
ID int
|
||||
ScopeID int
|
||||
ProjectID int
|
||||
Name string
|
||||
Status int
|
||||
Description string
|
||||
IsCoarse bool
|
||||
AggregateRequired int
|
||||
}
|
||||
|
||||
type ProjectRequirementStat struct {
|
||||
|
||||
@@ -156,17 +156,18 @@ func (q *Queries) InsertProject(ctx context.Context, arg InsertProjectParams) (s
|
||||
}
|
||||
|
||||
const insertProjectRequirement = `-- name: InsertProjectRequirement :execresult
|
||||
INSERT INTO project_requirement (scope_id, project_id, name, status, description, is_coarse)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
INSERT INTO project_requirement (scope_id, project_id, name, status, description, is_coarse, aggregate_required)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
`
|
||||
|
||||
type InsertProjectRequirementParams struct {
|
||||
ScopeID int
|
||||
ProjectID int
|
||||
Name string
|
||||
Status int
|
||||
Description string
|
||||
IsCoarse bool
|
||||
ScopeID int
|
||||
ProjectID int
|
||||
Name string
|
||||
Status int
|
||||
Description string
|
||||
IsCoarse bool
|
||||
AggregateRequired int
|
||||
}
|
||||
|
||||
func (q *Queries) InsertProjectRequirement(ctx context.Context, arg InsertProjectRequirementParams) (sql.Result, error) {
|
||||
@@ -177,11 +178,12 @@ func (q *Queries) InsertProjectRequirement(ctx context.Context, arg InsertProjec
|
||||
arg.Status,
|
||||
arg.Description,
|
||||
arg.IsCoarse,
|
||||
arg.AggregateRequired,
|
||||
)
|
||||
}
|
||||
|
||||
const listProjectRequirements = `-- name: ListProjectRequirements :many
|
||||
SELECT id, scope_id, project_id, name, status, description, is_coarse FROM project_requirement WHERE project_id = ?
|
||||
SELECT id, scope_id, project_id, name, status, description, is_coarse, aggregate_required FROM project_requirement WHERE project_id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) ListProjectRequirements(ctx context.Context, projectID int) ([]ProjectRequirement, error) {
|
||||
@@ -201,6 +203,7 @@ func (q *Queries) ListProjectRequirements(ctx context.Context, projectID int) ([
|
||||
&i.Status,
|
||||
&i.Description,
|
||||
&i.IsCoarse,
|
||||
&i.AggregateRequired,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -330,17 +333,19 @@ UPDATE project_requirement
|
||||
SET name = ?,
|
||||
status = ?,
|
||||
description = ?,
|
||||
is_coarse = ?
|
||||
is_coarse = ?,
|
||||
aggregate_required = ?
|
||||
WHERE id = ? AND scope_id = ?
|
||||
`
|
||||
|
||||
type UpdateProjectRequirementParams struct {
|
||||
Name string
|
||||
Status int
|
||||
Description string
|
||||
IsCoarse bool
|
||||
ID int
|
||||
ScopeID int
|
||||
Name string
|
||||
Status int
|
||||
Description string
|
||||
IsCoarse bool
|
||||
AggregateRequired int
|
||||
ID int
|
||||
ScopeID int
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateProjectRequirement(ctx context.Context, arg UpdateProjectRequirementParams) error {
|
||||
@@ -349,6 +354,7 @@ func (q *Queries) UpdateProjectRequirement(ctx context.Context, arg UpdateProjec
|
||||
arg.Status,
|
||||
arg.Description,
|
||||
arg.IsCoarse,
|
||||
arg.AggregateRequired,
|
||||
arg.ID,
|
||||
arg.ScopeID,
|
||||
)
|
||||
|
||||
+24
-20
@@ -194,7 +194,7 @@ func (r *projectRepository) FetchRequirements(ctx context.Context, scopeID int,
|
||||
return []entities.Requirement{}, []entities.RequirementStat{}, nil
|
||||
}
|
||||
|
||||
sq := squirrel.Select("id, scope_id, project_id, name, status, description, is_coarse").
|
||||
sq := squirrel.Select("id, scope_id, project_id, name, status, description, is_coarse, aggregate_required").
|
||||
From("project_requirement").
|
||||
Where(squirrel.Eq{"id": requirementIDs})
|
||||
if scopeID != -1 {
|
||||
@@ -221,6 +221,7 @@ func (r *projectRepository) FetchRequirements(ctx context.Context, scopeID int,
|
||||
&requirement.Status,
|
||||
&requirement.Description,
|
||||
&requirement.IsCoarse,
|
||||
&requirement.AggregateRequired,
|
||||
); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -271,13 +272,14 @@ func (r *projectRepository) ListRequirements(ctx context.Context, projectID int)
|
||||
requirements := make([]entities.Requirement, 0, len(reqRows))
|
||||
for _, row := range reqRows {
|
||||
requirements = append(requirements, entities.Requirement{
|
||||
ID: row.ID,
|
||||
ScopeID: row.ScopeID,
|
||||
ProjectID: row.ProjectID,
|
||||
Name: row.Name,
|
||||
Description: row.Description,
|
||||
IsCoarse: row.IsCoarse,
|
||||
Status: models.Status(row.Status),
|
||||
ID: row.ID,
|
||||
ScopeID: row.ScopeID,
|
||||
ProjectID: row.ProjectID,
|
||||
Name: row.Name,
|
||||
Description: row.Description,
|
||||
IsCoarse: row.IsCoarse,
|
||||
AggregateRequired: row.AggregateRequired,
|
||||
Status: models.Status(row.Status),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -295,12 +297,13 @@ func (r *projectRepository) ListRequirements(ctx context.Context, projectID int)
|
||||
|
||||
func (r *projectRepository) CreateRequirement(ctx context.Context, requirement entities.Requirement) (*entities.Requirement, error) {
|
||||
res, err := r.q.InsertProjectRequirement(ctx, mysqlcore.InsertProjectRequirementParams{
|
||||
ScopeID: requirement.ScopeID,
|
||||
ProjectID: requirement.ProjectID,
|
||||
Name: requirement.Name,
|
||||
Status: int(requirement.Status),
|
||||
Description: requirement.Description,
|
||||
IsCoarse: requirement.IsCoarse,
|
||||
ScopeID: requirement.ScopeID,
|
||||
ProjectID: requirement.ProjectID,
|
||||
Name: requirement.Name,
|
||||
Status: int(requirement.Status),
|
||||
Description: requirement.Description,
|
||||
IsCoarse: requirement.IsCoarse,
|
||||
AggregateRequired: requirement.AggregateRequired,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -319,12 +322,13 @@ func (r *projectRepository) UpdateRequirement(ctx context.Context, requirement e
|
||||
requirement.Update(update)
|
||||
|
||||
return r.q.UpdateProjectRequirement(ctx, mysqlcore.UpdateProjectRequirementParams{
|
||||
Name: requirement.Name,
|
||||
Status: int(requirement.Status),
|
||||
Description: requirement.Description,
|
||||
IsCoarse: requirement.IsCoarse,
|
||||
ID: requirement.ID,
|
||||
ScopeID: requirement.ScopeID,
|
||||
Name: requirement.Name,
|
||||
Status: int(requirement.Status),
|
||||
Description: requirement.Description,
|
||||
IsCoarse: requirement.IsCoarse,
|
||||
ID: requirement.ID,
|
||||
ScopeID: requirement.ScopeID,
|
||||
AggregateRequired: requirement.AggregateRequired,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -23,15 +23,16 @@ DELETE FROM project WHERE id = ? AND scope_id = ?;
|
||||
SELECT * FROM project_requirement WHERE project_id = ?;
|
||||
|
||||
-- name: InsertProjectRequirement :execresult
|
||||
INSERT INTO project_requirement (scope_id, project_id, name, status, description, is_coarse)
|
||||
VALUES (?, ?, ?, ?, ?, ?);
|
||||
INSERT INTO project_requirement (scope_id, project_id, name, status, description, is_coarse, aggregate_required)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?);
|
||||
|
||||
-- name: UpdateProjectRequirement :exec
|
||||
UPDATE project_requirement
|
||||
SET name = ?,
|
||||
status = ?,
|
||||
description = ?,
|
||||
is_coarse = ?
|
||||
is_coarse = ?,
|
||||
aggregate_required = ?
|
||||
WHERE id = ? AND scope_id = ?;
|
||||
|
||||
-- name: DeleteProjectRequirement :exec
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE project_requirement ADD COLUMN aggregate_required INT NOT NULL DEFAULT 0;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE project_requirement DROP COLUMN aggregate_required;
|
||||
-- +goose StatementEnd
|
||||
+25
-19
@@ -53,17 +53,18 @@ func (r *Result) Requirement(id int) *RequirementResult {
|
||||
}
|
||||
|
||||
type RequirementResult struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Status models.Status `json:"status"`
|
||||
StatusName string `json:"statusName"`
|
||||
TotalAcquired float64 `json:"totalAcquired"`
|
||||
TotalRequired float64 `json:"totalRequired"`
|
||||
TotalPlanned float64 `json:"totalPlanned"`
|
||||
IsCoarse bool `json:"isCoarse"`
|
||||
Stats []RequirementResultStat `json:"stats"`
|
||||
Items []items.Result `json:"items"`
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Status models.Status `json:"status"`
|
||||
StatusName string `json:"statusName"`
|
||||
TotalAcquired float64 `json:"totalAcquired"`
|
||||
TotalRequired float64 `json:"totalRequired"`
|
||||
TotalPlanned float64 `json:"totalPlanned"`
|
||||
IsCoarse bool `json:"isCoarse"`
|
||||
AggregateRequired int `json:"aggregateRequired"`
|
||||
Stats []RequirementResultStat `json:"stats"`
|
||||
Items []items.Result `json:"items"`
|
||||
|
||||
Requirement entities.Requirement `json:"-"`
|
||||
}
|
||||
@@ -161,14 +162,15 @@ func generateResult(
|
||||
|
||||
func generateRequirementResult(req entities.Requirement, scope scopes.Result, requirementStats []entities.RequirementStat, projectItems []items.Result) RequirementResult {
|
||||
resReq := RequirementResult{
|
||||
ID: req.ID,
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
Status: req.Status,
|
||||
StatusName: scope.StatusName(req.Status),
|
||||
IsCoarse: req.IsCoarse,
|
||||
Stats: make([]RequirementResultStat, 0, 8),
|
||||
Items: make([]items.Result, 0, 8),
|
||||
ID: req.ID,
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
Status: req.Status,
|
||||
StatusName: scope.StatusName(req.Status),
|
||||
IsCoarse: req.IsCoarse,
|
||||
AggregateRequired: req.AggregateRequired,
|
||||
Stats: make([]RequirementResultStat, 0, 8),
|
||||
Items: make([]items.Result, 0, 8),
|
||||
|
||||
Requirement: req,
|
||||
}
|
||||
@@ -271,6 +273,10 @@ func generateRequirementResult(req entities.Requirement, scope scopes.Result, re
|
||||
resReq.TotalRequired += item.WeightedRequired
|
||||
}
|
||||
resReq.TotalPlanned = resReq.TotalRequired
|
||||
|
||||
if req.AggregateRequired > 0 {
|
||||
resReq.TotalRequired = float64(req.AggregateRequired)
|
||||
}
|
||||
}
|
||||
|
||||
return resReq
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package sprints
|
||||
|
||||
import (
|
||||
"git.aiterp.net/stufflog3/stufflog3/models"
|
||||
"time"
|
||||
)
|
||||
|
||||
type BurndownDataPoint struct {
|
||||
Date models.Date `json:"date"`
|
||||
Value float64 `json:"value"`
|
||||
}
|
||||
|
||||
type burndownGenerator struct {
|
||||
Points []BurndownDataPoint
|
||||
}
|
||||
|
||||
func (g *burndownGenerator) Add(t time.Time, v float64) {
|
||||
t = t.In(tz).Add(-time.Minute * 300)
|
||||
yyyy, mm, dd := t.Date()
|
||||
date := models.Date{yyyy, int(mm), dd}
|
||||
|
||||
found := false
|
||||
insertIndex := -1
|
||||
for i, p := range g.Points {
|
||||
if date == p.Date {
|
||||
found = true
|
||||
break
|
||||
} else if date.Before(p.Date) {
|
||||
insertIndex = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
if insertIndex == -1 {
|
||||
value := 0.0
|
||||
if len(g.Points) > 0 {
|
||||
value = g.Points[len(g.Points)-1].Value
|
||||
}
|
||||
|
||||
g.Points = append(g.Points, BurndownDataPoint{
|
||||
Date: date,
|
||||
Value: value,
|
||||
})
|
||||
} else {
|
||||
g.Points = append(g.Points[:insertIndex+1], g.Points[insertIndex:]...)
|
||||
g.Points[insertIndex].Date = date
|
||||
if insertIndex > 0 {
|
||||
g.Points[insertIndex].Value = g.Points[insertIndex-1].Value
|
||||
} else {
|
||||
g.Points[insertIndex].Value = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for i, p := range g.Points {
|
||||
if !p.Date.Before(date) {
|
||||
g.Points[i].Value += v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var tz *time.Location
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
|
||||
tz, err = time.LoadLocation("Europe/Oslo")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package sprints
|
||||
|
||||
import (
|
||||
"git.aiterp.net/stufflog3/stufflog3/models"
|
||||
"github.com/go-playground/assert/v2"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestBurndownGenerator_Add(t *testing.T) {
|
||||
bg := burndownGenerator{}
|
||||
|
||||
// This is too early on the second, and counts as the first.
|
||||
bg.Add(td(3, 2, 20), 14)
|
||||
assert.Equal(t, bg.Points, []BurndownDataPoint{
|
||||
{Date: d(2), Value: 14},
|
||||
})
|
||||
|
||||
// Add some more data points in order
|
||||
bg.Add(td(3, 14, 11), 4)
|
||||
bg.Add(td(4, 6, 44), 3)
|
||||
bg.Add(td(21, 11, 24), 20)
|
||||
assert.Equal(t, bg.Points, []BurndownDataPoint{
|
||||
{Date: d(2), Value: 14},
|
||||
{Date: d(3), Value: 18},
|
||||
{Date: d(4), Value: 21},
|
||||
{Date: d(21), Value: 41},
|
||||
})
|
||||
|
||||
// Add ones out of order.
|
||||
bg.Add(td(7, 21, 12), 2)
|
||||
bg.Add(td(2, 15, 22), 1)
|
||||
assert.Equal(t, bg.Points, []BurndownDataPoint{
|
||||
{Date: d(2), Value: 15},
|
||||
{Date: d(3), Value: 19},
|
||||
{Date: d(4), Value: 22},
|
||||
{Date: d(7), Value: 24},
|
||||
{Date: d(21), Value: 44},
|
||||
})
|
||||
|
||||
// Add one at the start
|
||||
bg.Add(td(1, 11, 16), 1)
|
||||
assert.Equal(t, bg.Points, []BurndownDataPoint{
|
||||
{Date: d(1), Value: 1},
|
||||
{Date: d(2), Value: 16},
|
||||
{Date: d(3), Value: 20},
|
||||
{Date: d(4), Value: 23},
|
||||
{Date: d(7), Value: 25},
|
||||
{Date: d(21), Value: 45},
|
||||
})
|
||||
|
||||
// Add one more in the middle for good measure
|
||||
bg.Add(td(5, 14, 33), 10)
|
||||
assert.Equal(t, bg.Points, []BurndownDataPoint{
|
||||
{Date: d(1), Value: 1},
|
||||
{Date: d(2), Value: 16},
|
||||
{Date: d(3), Value: 20},
|
||||
{Date: d(4), Value: 23},
|
||||
{Date: d(5), Value: 33},
|
||||
{Date: d(7), Value: 35},
|
||||
{Date: d(21), Value: 55},
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func d(dd int) models.Date {
|
||||
return models.Date{2022, 7, dd}
|
||||
}
|
||||
|
||||
func td(dd, hh, mm int) time.Time {
|
||||
return time.Date(2022, time.July, dd, hh, mm, 17, 0, time.UTC)
|
||||
}
|
||||
@@ -9,18 +9,20 @@ import (
|
||||
type Result struct {
|
||||
entities.Sprint
|
||||
|
||||
AggregateAcquired int `json:"aggregateAcquired"`
|
||||
AggregatePlanned int `json:"aggregatePlanned"`
|
||||
AggregateAcquired float64 `json:"aggregateAcquired"`
|
||||
AggregatePlanned float64 `json:"aggregatePlanned"`
|
||||
|
||||
ItemsAcquired *int `json:"itemsAcquired,omitempty"`
|
||||
ItemsRequired *int `json:"itemsRequired,omitempty"`
|
||||
|
||||
PartIDs []int `json:"partIds"` // Just for simplifying code.
|
||||
|
||||
Items []items.Result `json:"items,omitempty"`
|
||||
Stats []entities.Stat `json:"stats,omitempty"`
|
||||
Requirements []projects.RequirementResult `json:"requirements,omitempty"`
|
||||
Progress []ResultProgress `json:"progress,omitempty"`
|
||||
Items []items.Result `json:"items,omitempty"`
|
||||
Stats []entities.Stat `json:"stats,omitempty"`
|
||||
Requirements []projects.RequirementResult `json:"requirements,omitempty"`
|
||||
Progress []ResultProgress `json:"progress,omitempty"`
|
||||
ItemBurndown []BurndownDataPoint `json:"itemBurndown,omitempty"`
|
||||
AggregateBurndown []BurndownDataPoint `json:"aggregateBurndown,omitempty"`
|
||||
}
|
||||
|
||||
type ResultProgress struct {
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"git.aiterp.net/stufflog3/stufflog3/usecases/projects"
|
||||
"git.aiterp.net/stufflog3/stufflog3/usecases/scopes"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"math"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -85,6 +84,7 @@ func (s *Service) ListScopedBetween(ctx context.Context, from, to time.Time) ([]
|
||||
}
|
||||
|
||||
func (s *Service) fillMany(ctx context.Context, sprints []entities.Sprint) ([]Result, error) {
|
||||
now := time.Now()
|
||||
sort.Slice(sprints, func(i, j int) bool {
|
||||
si := sprints[i]
|
||||
sj := sprints[j]
|
||||
@@ -93,6 +93,12 @@ func (s *Service) fillMany(ctx context.Context, sprints []entities.Sprint) ([]Re
|
||||
return si.IsTimed
|
||||
}
|
||||
|
||||
siActive := si.ToTime.After(now)
|
||||
sjActive := sj.ToTime.After(now)
|
||||
if sjActive != siActive {
|
||||
return siActive
|
||||
}
|
||||
|
||||
if !si.FromTime.Equal(sj.FromTime) {
|
||||
return si.FromTime.Before(sj.FromTime)
|
||||
}
|
||||
@@ -550,17 +556,32 @@ func (s *Service) fill(ctx context.Context, sprint entities.Sprint, parts []enti
|
||||
})
|
||||
|
||||
// Measure progress
|
||||
itemBurndown := burndownGenerator{}
|
||||
aggregateBurndown := burndownGenerator{}
|
||||
for _, item := range res.Items {
|
||||
if !item.AcquiredBetween(sprint.FromTime, sprint.ToTime) {
|
||||
continue
|
||||
}
|
||||
|
||||
itemBurndown.Add(*item.AcquiredTime, 1)
|
||||
|
||||
itemAggregate := 0.0
|
||||
for _, stat := range item.Stats {
|
||||
if pi, ok := progressMap[stat.ID]; ok {
|
||||
res.Progress[pi].Acquired += stat.Acquired
|
||||
|
||||
if res.IsUnweighted {
|
||||
itemAggregate += float64(stat.Acquired)
|
||||
} else {
|
||||
itemAggregate += float64(stat.Acquired) * stat.Weight
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aggregateBurndown.Add(*item.AcquiredTime, itemAggregate)
|
||||
}
|
||||
res.AggregateBurndown = aggregateBurndown.Points
|
||||
res.ItemBurndown = itemBurndown.Points
|
||||
|
||||
// For requirement sprints, remove items array after enumeration
|
||||
if res.Kind == models.SprintKindRequirements {
|
||||
@@ -583,11 +604,11 @@ func (s *Service) fill(ctx context.Context, sprint entities.Sprint, parts []enti
|
||||
}
|
||||
}
|
||||
}
|
||||
res.AggregateAcquired = int(math.Round(aggregateAcquired))
|
||||
res.AggregatePlanned = int(math.Round(aggregatePlanned))
|
||||
res.AggregateAcquired = aggregateAcquired
|
||||
res.AggregatePlanned = aggregatePlanned
|
||||
|
||||
if res.AggregateRequired < 0 {
|
||||
res.AggregateRequired = res.AggregatePlanned
|
||||
res.AggregateRequired = int(res.AggregatePlanned)
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
|
||||
Reference in New Issue
Block a user