extract all simulation to the dashboard store
This commit is contained in:
@@ -1,10 +1,26 @@
|
|||||||
import { Dashboard } from '@/store-type'
|
import { featureSteps } from '@/modules/feature/feature-steps'
|
||||||
|
import { Strategy } from '@/modules/lean/strategy'
|
||||||
|
import { Dashboard, Meta } from '@/store-type'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
dashboards: Dashboard[]
|
dashboards: Dashboard[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const instance = new ComlinkWorker<typeof import('../feature/feature-board')>(
|
||||||
|
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', {
|
export const useDashboardStore = defineStore('dashboard', {
|
||||||
state: (): State => {
|
state: (): State => {
|
||||||
return {
|
return {
|
||||||
@@ -15,6 +31,44 @@ export const useDashboardStore = defineStore('dashboard', {
|
|||||||
newDashboard(dashboard: Dashboard) {
|
newDashboard(dashboard: Dashboard) {
|
||||||
this.dashboards.push(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() {
|
clearDashboard() {
|
||||||
this.dashboards = []
|
this.dashboards = []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useFeatureStore } from '@/modules/feature/feature-store'
|
import { useDashboardStore } from '@/modules/dashboard/dashboard-store'
|
||||||
|
|
||||||
const featureStore = useFeatureStore()
|
const dashboardStore = useDashboardStore()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="feature-dashboard">
|
<div class="feature-dashboard">
|
||||||
Dashboard
|
Dashboard
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="dashboard in featureStore.dashboards" :key="dashboard.uuid">
|
<li v-for="dashboard in dashboardStore.dashboards" :key="dashboard.uuid">
|
||||||
{{ dashboard.analysis.mainStrategy }}: mean lead time
|
{{ dashboard.analysis.mainStrategy }}: mean lead time
|
||||||
{{ dashboard.analysis.meanLeadTime }} | worst feature for quality
|
{{ dashboard.analysis.meanLeadTime }} | worst feature for quality
|
||||||
{{ dashboard.analysis.worstFeature.qualityIssue }} [{{
|
{{ dashboard.analysis.worstFeature.qualityIssue }} [{{
|
||||||
|
|||||||
@@ -47,16 +47,16 @@ const pushAndProblemSolving20Percent = () => {
|
|||||||
<button @click="featureStore.nextDay('problem-solving')">
|
<button @click="featureStore.nextDay('problem-solving')">
|
||||||
problem solving
|
problem solving
|
||||||
</button>
|
</button>
|
||||||
<button @click="featureStore.simulate('push')">
|
<button @click="dashboardStore.simulate('push')">
|
||||||
simulate push system
|
simulate push system
|
||||||
</button>
|
</button>
|
||||||
<button @click="featureStore.simulate('pull')">
|
<button @click="dashboardStore.simulate('pull')">
|
||||||
simulate pull system
|
simulate pull system
|
||||||
</button>
|
</button>
|
||||||
<button @click="featureStore.simulate100('pull')">
|
<button @click="dashboardStore.simulate100('pull')">
|
||||||
simulate 100 pull system
|
simulate 100 pull system
|
||||||
</button>
|
</button>
|
||||||
<button @click="featureStore.simulate('problem-solving')">
|
<button @click="dashboardStore.simulate('problem-solving')">
|
||||||
simulate pull and problem solving
|
simulate pull and problem solving
|
||||||
</button>
|
</button>
|
||||||
<button @click="dashboardStore.clearDashboard()">clear dashboard</button>
|
<button @click="dashboardStore.clearDashboard()">clear dashboard</button>
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import { useDashboardStore } from '@/modules/dashboard/dashboard-store'
|
|
||||||
import { Feature } from '@/modules/feature/feature'
|
import { Feature } from '@/modules/feature/feature'
|
||||||
import {
|
import {
|
||||||
|
initBoard,
|
||||||
meanComplexity,
|
meanComplexity,
|
||||||
meanLeadTime,
|
meanLeadTime,
|
||||||
meanQualityIssue
|
meanQualityIssue,
|
||||||
|
newBacklog,
|
||||||
|
nextDay
|
||||||
} from '@/modules/feature/feature-board'
|
} from '@/modules/feature/feature-board'
|
||||||
import { featureSteps } from '@/modules/feature/feature-steps'
|
import { featureSteps } from '@/modules/feature/feature-steps'
|
||||||
import { Strategy } from '@/modules/lean/strategy'
|
import { Strategy } from '@/modules/lean/strategy'
|
||||||
@@ -11,12 +13,6 @@ import { FeatureState, Meta } from '@/store-type'
|
|||||||
import { clone } from '@/utils'
|
import { clone } from '@/utils'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
const dashboardStore = useDashboardStore()
|
|
||||||
|
|
||||||
const instance = new ComlinkWorker<typeof import('./feature-board')>(
|
|
||||||
new URL('./feature-board', import.meta.url)
|
|
||||||
)
|
|
||||||
|
|
||||||
const resetMeta = (): Meta => ({
|
const resetMeta = (): Meta => ({
|
||||||
totalDays: 0,
|
totalDays: 0,
|
||||||
daysWithProblemSolving: 0,
|
daysWithProblemSolving: 0,
|
||||||
@@ -36,13 +32,9 @@ export const useFeatureStore = defineStore('feature', {
|
|||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
async initBoard() {
|
async initBoard() {
|
||||||
const newBacklog = await instance.newBacklog()
|
this.backlog = newBacklog()
|
||||||
this.backlog = newBacklog
|
|
||||||
this.steps = featureSteps
|
this.steps = featureSteps
|
||||||
this.features = await instance.initBoard(
|
this.features = initBoard(clone(this.steps), clone(this.backlog))
|
||||||
clone(this.steps),
|
|
||||||
clone(this.backlog)
|
|
||||||
)
|
|
||||||
|
|
||||||
this.backlog = this.backlog.filter(
|
this.backlog = this.backlog.filter(
|
||||||
(l) => !this.features.find((f) => f.name === l.name)
|
(l) => !this.features.find((f) => f.name === l.name)
|
||||||
@@ -50,49 +42,11 @@ export const useFeatureStore = defineStore('feature', {
|
|||||||
this.meta = resetMeta()
|
this.meta = resetMeta()
|
||||||
},
|
},
|
||||||
async nextDay(strategy: Strategy) {
|
async nextDay(strategy: Strategy) {
|
||||||
const newState = await instance.nextDay(clone(this.$state), strategy)
|
const newState = nextDay(clone(this.$state), strategy)
|
||||||
|
|
||||||
this.backlog = newState.backlog
|
this.backlog = newState.backlog
|
||||||
this.meta = newState.meta
|
this.meta = newState.meta
|
||||||
this.features = newState.features
|
this.features = newState.features
|
||||||
},
|
|
||||||
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
|
|
||||||
)
|
|
||||||
|
|
||||||
dashboardStore.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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
|
|||||||
Reference in New Issue
Block a user