Skip to content

Commit

Permalink
refactor: move test data to central local repository.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunoacc committed Apr 20, 2023
1 parent 8630d30 commit 34bbc08
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 83 deletions.
82 changes: 82 additions & 0 deletions src/data/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
export default {
measurements: [
{
assetId: 0,
measurements: {
'2020-01-01T00:00:00.000Z': 156,
'2020-02-01T00:00:00.000Z': 123,
'2020-03-01T00:00:00.000Z': 128,
'2020-04-01T00:00:00.000Z': 159,
'2020-05-01T00:00:00.000Z': 178,
'2020-06-01T00:00:00.000Z': 290,
'2020-07-01T00:00:00.000Z': 276,
'2020-08-01T00:00:00.000Z': 250,
'2020-09-01T00:00:00.000Z': 156,
'2020-10-01T00:00:00.000Z': 176,
'2020-11-01T00:00:00.000Z': 134,
'2020-12-01T00:00:00.000Z': 111
}
},
{
assetId: 2,
measurements: {
'2020-01-01T00:00:00.000Z': 141,
'2020-02-01T00:00:00.000Z': 125,
'2020-03-01T00:00:00.000Z': 113,
'2020-04-01T00:00:00.000Z': 151,
'2020-05-01T00:00:00.000Z': 107,
'2020-06-01T00:00:00.000Z': 116,
'2020-07-01T00:00:00.000Z': 125,
'2020-08-01T00:00:00.000Z': 146,
'2020-09-01T00:00:00.000Z': 101,
'2020-10-01T00:00:00.000Z': 126,
'2020-11-01T00:00:00.000Z': 151,
'2020-12-01T00:00:00.000Z': 148
}
},
{
assetId: 4,
measurements: {
'2020-01-01T00:00:00.000Z': 142,
'2020-02-01T00:00:00.000Z': 164,
'2020-03-01T00:00:00.000Z': 112,
'2020-04-01T00:00:00.000Z': 114,
'2020-05-01T00:00:00.000Z': 170,
'2020-06-01T00:00:00.000Z': 130,
'2020-07-01T00:00:00.000Z': 132,
'2020-08-01T00:00:00.000Z': 129,
'2020-09-01T00:00:00.000Z': 157,
'2020-10-01T00:00:00.000Z': 128,
'2020-11-01T00:00:00.000Z': 110,
'2020-12-01T00:00:00.000Z': 168
}
}
],
assets: [
{
id: 0,
name: 'Asset 0',
parentId: undefined
},
{
id: 1,
name: 'Asset 1',
parentId: undefined
},
{
id: 2,
name: 'Asset 2',
parentId: 1
},
{
id: 3,
name: 'Asset 3',
parentId: 1
},
{
id: 4,
name: 'Asset 4',
parentId: 3
}
]
}
32 changes: 2 additions & 30 deletions src/stores/assets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Api } from '@/api'
import data from '@/data'
import type { AssetTreeMeasurements } from '@/helpers/aggregateMeasurements'
import type { Assets } from '@/interfaces/asset.interface'
import { defineStore } from 'pinia'
Expand All @@ -17,36 +18,7 @@ export const useAssetsStore = defineStore('assets', () => {
// we could use this to fetch from an API
// assets.value = await Api.assets.getAll()

assets.value = []
assets.value.push(
...[
{
id: 0,
name: 'Asset 0',
parentId: undefined
},
{
id: 1,
name: 'Asset 1',
parentId: undefined
},
{
id: 2,
name: 'Asset 2',
parentId: 1
},
{
id: 3,
name: 'Asset 3',
parentId: 1
},
{
id: 4,
name: 'Asset 4',
parentId: 3
}
]
)
assets.value = [...data.assets]
}

onMounted(async () => await fetchAssets())
Expand Down
55 changes: 2 additions & 53 deletions src/stores/measurements.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Api } from '@/api'
import data from '@/data'
import type { Measurements } from '@/interfaces/measurements.interface'
import { defineStore } from 'pinia'
import { onMounted, ref } from 'vue'
Expand All @@ -10,59 +11,7 @@ export const useMeasurementsStore = defineStore('measurements', () => {
// we could use this to fetch from an API
// measurements.value = await Api.measurements.getAll()

measurements.value = [
{
assetId: 0,
measurements: {
'2020-01-01T00:00:00.000Z': 156,
'2020-02-01T00:00:00.000Z': 123,
'2020-03-01T00:00:00.000Z': 128,
'2020-04-01T00:00:00.000Z': 159,
'2020-05-01T00:00:00.000Z': 178,
'2020-06-01T00:00:00.000Z': 290,
'2020-07-01T00:00:00.000Z': 276,
'2020-08-01T00:00:00.000Z': 250,
'2020-09-01T00:00:00.000Z': 156,
'2020-10-01T00:00:00.000Z': 176,
'2020-11-01T00:00:00.000Z': 134,
'2020-12-01T00:00:00.000Z': 111
}
},
{
assetId: 2,
measurements: {
'2020-01-01T00:00:00.000Z': 141,
'2020-02-01T00:00:00.000Z': 125,
'2020-03-01T00:00:00.000Z': 113,
'2020-04-01T00:00:00.000Z': 151,
'2020-05-01T00:00:00.000Z': 107,
'2020-06-01T00:00:00.000Z': 116,
'2020-07-01T00:00:00.000Z': 125,
'2020-08-01T00:00:00.000Z': 146,
'2020-09-01T00:00:00.000Z': 101,
'2020-10-01T00:00:00.000Z': 126,
'2020-11-01T00:00:00.000Z': 151,
'2020-12-01T00:00:00.000Z': 148
}
},
{
assetId: 4,
measurements: {
'2020-01-01T00:00:00.000Z': 142,
'2020-02-01T00:00:00.000Z': 164,
'2020-03-01T00:00:00.000Z': 112,
'2020-04-01T00:00:00.000Z': 114,
'2020-05-01T00:00:00.000Z': 170,
'2020-06-01T00:00:00.000Z': 130,
'2020-07-01T00:00:00.000Z': 132,
'2020-08-01T00:00:00.000Z': 129,
'2020-09-01T00:00:00.000Z': 157,
'2020-10-01T00:00:00.000Z': 128,
'2020-11-01T00:00:00.000Z': 110,
'2020-12-01T00:00:00.000Z': 168
}
}
]
measurements.value = [...data.measurements]
}

onMounted(async () => await fetchMeasurements())
Expand Down

1 comment on commit 34bbc08

@vercel
Copy link

@vercel vercel bot commented on 34bbc08 Apr 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.