Skip to content

Commit

Permalink
Merge pull request #183 from KaiShoya/bugfix/#182_sum_count_was_not_u…
Browse files Browse the repository at this point in the history
…pdated

release v1.12.3
  • Loading branch information
KaiShoya committed Apr 1, 2024
2 parents c96a0ac + dfe8d6f commit e7a6314
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
13 changes: 5 additions & 8 deletions components/pages/data/AggregationByDrinksTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
lang="ts"
>
import { useAggregationByDrinksStore } from '~/store/pages/data/components/aggregationByDrinks'
const { $i18n } = useNuxtApp()
const { chartDataTitle, computedTableData } = storeToRefs(useAggregationByDrinksStore())
const footers = [
$i18n.t('data.total'),
computedTableData.value.reduce((accumulator, currentValue) => accumulator + Number(currentValue[1]), 0),
]
const { chartDataTitle, computedTableData, computedSumCount } = storeToRefs(useAggregationByDrinksStore())
</script>

<template>
<MoleculesBaseTable
:headers="chartDataTitle"
:table-data="computedTableData"
:footers="footers"
:footers="[
$t('data.total'),
computedSumCount,
]"
/>
</template>
6 changes: 5 additions & 1 deletion components/pages/data/graphs/ComboChart.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<script setup lang="ts">
<script
setup
lang="ts"
>
import { GChart } from 'vue-google-charts'
withDefaults(defineProps<{
data: Array<Array<String | Number>>,
Expand All @@ -14,6 +17,7 @@ withDefaults(defineProps<{

<template>
<GChart
v-if="data.length > 1"
type="ComboChart"
:data="data"
:options="options"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drink-counter",
"version": "1.12.2",
"version": "1.12.3",
"license": "MIT",
"engines": {
"node": "20"
Expand Down
12 changes: 10 additions & 2 deletions store/pages/data/components/aggregationByDrinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const useAggregationByDrinksStore = defineStore('aggregationByDrinksStore
const drinksStore = useDrinksStore()
const { drinks } = storeToRefs(drinksStore)

const chartDataTitle = ['Name', 'Count']
const chartDataTitle = ref<Array<string>>(['Name', 'Count'])
const aggregationByDrinks = ref<Array<AggregationByDrink>>([])

const fetchSumCount = async () => {
Expand Down Expand Up @@ -48,11 +48,18 @@ export const useAggregationByDrinksStore = defineStore('aggregationByDrinksStore
)
})

/**
* 合計値計算ロジック
*/
const computedSumCount = computed(() => {
return computedTableData.value.reduce((accumulator, currentValue) => accumulator + Number(currentValue[1]), 0)
})

/**
* 円グラフ用データ
*/
const computedChartData = computed(() => {
return [chartDataTitle, ...computedTableData.value]
return [chartDataTitle.value, ...computedTableData.value]
})

/**
Expand All @@ -71,6 +78,7 @@ export const useAggregationByDrinksStore = defineStore('aggregationByDrinksStore
fetchSumCountPerYear,
fetchSumCountPerMonth,
computedTableData,
computedSumCount,
computedChartData,
computedPieChartOptions,
}
Expand Down
2 changes: 0 additions & 2 deletions store/pages/data/monthly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const useMonthlyStore = defineStore('monthlyStore', () => {
const { fetchSumCountPerMonth } = useAggregationByDrinksStore()

const graphDataTitleBase = ['日付', '合計']
const chartDataTitle = ['Name', 'Count']

const yearMonth = ref<string>(processIntoYearMonth(new Date()))
const graphDataTitle = ref<string[]>(graphDataTitleBase)
Expand Down Expand Up @@ -102,7 +101,6 @@ export const useMonthlyStore = defineStore('monthlyStore', () => {

return {
yearMonth,
chartDataTitle,
prevMonth,
nextMonth,
fetchDrinkCounters,
Expand Down
3 changes: 0 additions & 3 deletions store/pages/data/total.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export const useTotalStore = defineStore('totalStore', () => {
const { fetchAggregationByDow } = useAggregationByDowStore()
const { fetchSumCount } = useAggregationByDrinksStore()

const chartDataTitle = ['Name', 'Count']

const fetchDrinkCountersAll = async () => {
const fetchDrinksError = await fetchDrinks()
if (fetchDrinksError) {
Expand All @@ -36,7 +34,6 @@ export const useTotalStore = defineStore('totalStore', () => {
}

return {
chartDataTitle,
fetchDrinkCountersAll,
}
})

0 comments on commit e7a6314

Please sign in to comment.