diff --git a/src/App.vue b/src/App.vue index 2c5bb4d..52e1c29 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,5 +1,7 @@ @@ -8,6 +10,8 @@ import { StarportCarrier } from 'vue-starport' + + diff --git a/src/modules/dashboard/dashboard-store.ts b/src/modules/dashboard/dashboard-store.ts deleted file mode 100644 index eb779b7..0000000 --- a/src/modules/dashboard/dashboard-store.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { featureSteps } from '@/modules/feature/feature-steps' -import { Strategy } from '@/modules/lean/strategy' -import { Dashboard, Meta } from '@/store-type' -import { defineStore } from 'pinia' - -type State = { - dashboards: Dashboard[] -} - -const instance = new ComlinkWorker( - new URL('../feature/feature-board', import.meta.url) -) - -const resetMeta = (): Meta => ({ - totalDays: 0, - daysWithProblemSolving: 0, - strategy: { - push: 0, - pull: 0, - 'problem-solving': 0 - } -}) - -export const useDashboardStore = defineStore('dashboard', { - state: (): State => { - return { - dashboards: [] - } - }, - actions: { - newDashboard(dashboard: Dashboard) { - this.dashboards.push(dashboard) - }, - async simulate(strategy: Strategy) { - const backlog = await instance.newBacklog() - const steps = featureSteps - const features = await instance.initBoard(steps, backlog) - - const newState = await instance.simulate( - { - backlog, - steps, - features, - meta: resetMeta() - }, - strategy - ) - - const [worstFeature] = newState.features.sort((a, b) => - a.qualityIssue > b.qualityIssue ? -1 : 1 - ) - - this.newDashboard({ - uuid: new Date().getTime().toString(), - meta: newState.meta, - analysis: { - meanComplexity: await instance.meanComplexity(newState.features), - meanLeadTime: await instance.meanLeadTime(newState.features), - meanQualityIssue: await instance.meanQualityIssue(newState.features), - worstFeature, - mainStrategy: Object.entries(newState.meta.strategy).sort((a, b) => - a[1] > b[1] ? -1 : 1 - )[0][0] - } - }) - }, - async simulate100(strategy: Strategy) { - for (let i = 0; i < 100; i++) { - await this.simulate(strategy) - } - }, - clearDashboard() { - this.dashboards = [] - } - } -}) diff --git a/src/modules/feature/FeatureDashboard.vue b/src/modules/feature/FeatureDashboard.vue deleted file mode 100644 index 6555c79..0000000 --- a/src/modules/feature/FeatureDashboard.vue +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/src/modules/feature/FeatureSteps.vue b/src/modules/feature/FeatureSteps.vue index 9d2dd7d..7ed724a 100644 --- a/src/modules/feature/FeatureSteps.vue +++ b/src/modules/feature/FeatureSteps.vue @@ -1,13 +1,10 @@ + + diff --git a/src/modules/simulation/SimulationDashboard.vue b/src/modules/simulation/SimulationDashboard.vue new file mode 100644 index 0000000..929594c --- /dev/null +++ b/src/modules/simulation/SimulationDashboard.vue @@ -0,0 +1,43 @@ + + + + + diff --git a/src/modules/simulation/simulation-store.ts b/src/modules/simulation/simulation-store.ts new file mode 100644 index 0000000..2093250 --- /dev/null +++ b/src/modules/simulation/simulation-store.ts @@ -0,0 +1,108 @@ +import { featureSteps } from '@/modules/feature/feature-steps' +import { Strategy } from '@/modules/lean/strategy' +import { Dashboard, Meta } from '@/store-type' +import { getMean } from '@/utils' +import { defineStore } from 'pinia' + +type State = { + dashboards: Dashboard[] + requestedSimulation: number + simulationsDone: number +} + +const instance = new ComlinkWorker( + new URL('../feature/feature-board', import.meta.url) +) + +const resetMeta = (): Meta => ({ + totalDays: 0, + daysWithProblemSolving: 0, + strategy: { + push: 0, + pull: 0, + 'problem-solving': 0 + } +}) + +export const useSimulationStore = defineStore('dashboard', { + state: (): State => { + return { + dashboards: [], + requestedSimulation: 0, + simulationsDone: 0 + } + }, + actions: { + newDashboard(dashboard: Dashboard) { + this.dashboards.push(dashboard) + }, + async simulate(strategy: Strategy) { + const steps = featureSteps + const backlog = await instance.newBacklog() + const features = await instance.initBoard(steps, backlog) + + const newState = await instance.simulate( + { + backlog, + steps, + features, + meta: resetMeta() + }, + strategy + ) + + const [worstFeature] = newState.features.sort((a, b) => + a.qualityIssue > b.qualityIssue ? -1 : 1 + ) + + this.newDashboard({ + uuid: new Date().getTime().toString(), + meta: newState.meta, + analysis: { + meanComplexity: await instance.getMeanComplexity(newState.features), + meanLeadTime: await instance.getMeanLeadTime(newState.features), + meanQualityIssue: await instance.getMeanQualityIssue( + newState.features + ), + worstFeature, + strategy + } + }) + }, + async multiSimulation(simulations: number, strategy: Strategy) { + this.requestedSimulation += simulations + for (let i = 0; i < simulations; i++) { + await this.simulate(strategy) + this.simulationsDone++ + } + }, + clearDashboard() { + this.dashboards = [] + } + }, + getters: { + meanPushLeadTime: (state) => { + return getMean( + state.dashboards + .filter((dashboard) => dashboard.analysis.strategy === 'push') + .map((dashboard) => dashboard.analysis.meanLeadTime) + ) + }, + meanPullLeadTime: (state) => { + return getMean( + state.dashboards + .filter((dashboard) => dashboard.analysis.strategy === 'pull') + .map((dashboard) => dashboard.analysis.meanLeadTime) + ) + }, + meanPullDPSLeadTime: (state) => { + return getMean( + state.dashboards + .filter( + (dashboard) => dashboard.analysis.strategy === 'problem-solving' + ) + .map((dashboard) => dashboard.analysis.meanLeadTime) + ) + } + } +}) diff --git a/src/store-type.ts b/src/store-type.ts index 05b2284..a571603 100644 --- a/src/store-type.ts +++ b/src/store-type.ts @@ -13,7 +13,7 @@ export type Analysis = { meanQualityIssue: number meanComplexity: number meanLeadTime: number - mainStrategy: Strategy | string + strategy: Strategy | string } export type Dashboard = { diff --git a/src/utils.ts b/src/utils.ts index 98b2e41..7c1a93e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,3 +1,6 @@ +export const getMean = (data: number[]) => + Math.round(100 * (sumElements(data) / data.length)) / 100 + export const clone = (data: any) => JSON.parse(JSON.stringify(data)) export const shuffleArray = (array: T[]) => {