guesstimate/client/src/types/task.ts

54 lines
1.2 KiB
TypeScript

import { defaults } from "./params";
export type TaskID = string
export enum EstimationConfidence {
Optimistic = "optimistic",
Likely = "likely",
Pessimistic = "pessimistic"
}
export interface Task {
id: TaskID
label: string
category: TaskCategoryID
estimations: { [confidence in EstimationConfidence]: number }
}
export type TaskCategoryID = string
export interface TaskCategory {
id: TaskCategoryID
label: string
costPerTimeUnit: number
}
export function newTask(label: string, category: TaskCategoryID): Task {
return {
id: '',
label,
category,
estimations: {
[EstimationConfidence.Optimistic]: 0,
[EstimationConfidence.Likely]: 0,
[EstimationConfidence.Pessimistic]: 0,
}
};
}
export function createTaskCategory(): TaskCategory {
return {
id: '',
costPerTimeUnit: defaults.costPerTimeUnit,
label: ""
};
}
export function getTaskWeightedMean(t: Task): number {
return (t.estimations.optimistic + (4*t.estimations.likely) + t.estimations.pessimistic) / 6;
}
export function getTaskStandardDeviation(t: Task): number {
return (t.estimations.pessimistic - t.estimations.optimistic) / 6;
}