Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b381e2cbed | ||
|
|
d7c1fbb21c | ||
|
|
d4141f5eb3 | ||
|
|
1232721921 | ||
|
|
a70bb4bb23 | ||
|
|
0ba65038e9 | ||
|
|
6c3fdad79c | ||
|
|
e307ed6021 | ||
|
|
e4c41e1d47 | ||
|
|
ae47f1a0e5 | ||
|
|
b9ffe256e9 | ||
|
|
eff677cc69 | ||
|
|
702b2254c8 | ||
|
|
972ad748f2 | ||
|
|
2f4c03b9af |
+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 {
|
||||
|
||||
@@ -10,10 +10,19 @@
|
||||
|
||||
<div class="markdown">{@html outputHtml}</div>
|
||||
|
||||
<style>
|
||||
<style lang="scss">
|
||||
@import "../../css/colors.sass";
|
||||
|
||||
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) {
|
||||
@@ -58,6 +67,17 @@
|
||||
counter-reset: li;
|
||||
}
|
||||
|
||||
div.markdown :global(a) {
|
||||
color: #d1a31b;
|
||||
text-decoration: none;
|
||||
transition: 250ms;
|
||||
|
||||
&:hover {
|
||||
color: #FFCC11;
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
div.markdown :global(ul) :global(li:before) {
|
||||
content: "\2022"; /* Add content: \2022 is the CSS Code/unicode for a bullet */
|
||||
color: #333; /* Change the color */
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -0,0 +1,38 @@
|
||||
<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;
|
||||
export let aggregateRequired: number;
|
||||
|
||||
const {scope} = getScopeContext();
|
||||
|
||||
let amounts: {name: string, amount: number}[] = [];
|
||||
|
||||
$: {
|
||||
const statMap: Record<number, number> = {};
|
||||
|
||||
for (const item of items) {
|
||||
for (const stat of item.stats) {
|
||||
statMap[stat.id] = (statMap[stat.id] || 0) + stat.acquired
|
||||
}
|
||||
}
|
||||
|
||||
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 right label="" dark value={totalAcquired} target={aggregateRequired} />
|
||||
</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} />
|
||||
|
||||
@@ -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 on"
|
||||
} 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>
|
||||
@@ -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.getHours())}`;
|
||||
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}`;
|
||||
}
|
||||
}
|
||||
@@ -25,9 +25,9 @@ export default function parseInterval(s: string, date: Date): TimeInterval<Date>
|
||||
const [amount, unit] = unitNumber(args);
|
||||
switch (unit) {
|
||||
case "d": case "days":
|
||||
return {display: "days", min: startOfDay(addDays(date, -amount)), max: startOfDay(addDays(date, 1))}
|
||||
return {display: "days", min: startOfDay(addDays(date, -(amount - 1))), max: startOfDay(addDays(date, 1))}
|
||||
case "w": case "weeks":
|
||||
return {display: "weeks", min: startOfDay(addDays(date, -amount * 7)), max: startOfDay(addDays(date, 1))}
|
||||
return {display: "weeks", min: startOfDay(addDays(date, -((amount * 7) - 1))), max: startOfDay(addDays(date, 1))}
|
||||
case "m": case "months":
|
||||
return {display: "days", min: startOfDay(addMonths(date, -amount)), max: startOfDay(addDays(date, 1))}
|
||||
case "y": case "years":
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 495 KiB After Width: | Height: | Size: 112 KiB |
@@ -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"`
|
||||
}
|
||||
|
||||
@@ -43,6 +43,15 @@ func (s Status) Less(s2 Status) bool {
|
||||
return s < s2
|
||||
}
|
||||
|
||||
func (s Status) Ended() bool {
|
||||
switch s {
|
||||
case Completed, Failed, Dropped:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
Blocked Status = iota
|
||||
Available
|
||||
|
||||
@@ -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
|
||||
+30
-20
@@ -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:"-"`
|
||||
}
|
||||
@@ -136,8 +137,12 @@ func generateResult(
|
||||
resReq := generateRequirementResult(req, scope, requirementStats, projectItems)
|
||||
|
||||
res.TotalRequired += resReq.TotalRequired
|
||||
res.TotalAcquired += resReq.TotalAcquired
|
||||
res.TotalPlanned += resReq.TotalPlanned
|
||||
if req.Status.Ended() {
|
||||
res.TotalAcquired += resReq.TotalRequired
|
||||
} else {
|
||||
res.TotalAcquired += resReq.TotalAcquired
|
||||
}
|
||||
|
||||
res.Requirements = append(res.Requirements, resReq)
|
||||
}
|
||||
@@ -157,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,
|
||||
}
|
||||
@@ -267,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)
|
||||
}
|
||||
@@ -17,10 +17,12 @@ type Result struct {
|
||||
|
||||
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 {
|
||||
|
||||
@@ -550,17 +550,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 {
|
||||
|
||||
Reference in New Issue
Block a user