Skip to content

Commit

Permalink
#257 退院者情報が別APIになった件に対応
Browse files Browse the repository at this point in the history
  • Loading branch information
sugasaki committed Apr 25, 2020
1 parent 0d17633 commit c69b892
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 57 deletions.
48 changes: 4 additions & 44 deletions brigade/nagasaki/components/cards/ConfirmedCasesDetailsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,51 +63,11 @@ export default {
},
confirmedCases() {
// 検査陽性者の状況
const patientsNotCruise = this.$store.state.patientsNotCruise
// console.log(patientsNotCruise, 'patientsNotCruise')
// if (!patientsNotCruise) return formatConfirmedCases(summary)
const summary = Data.main_summary
// console.log(summary, 'summary')
const allCount = this.$store.state.allCount
const number = patientsNotCruise.length
const taiin = this.$store.state.patientsNotCruise.filter(
d => d.退院済フラグ === '1'
).length
const dead = this.$store.state.patientsNotCruise.filter(
d => d.死亡フラグ === '1'
).length
// console.log(taiin, 'taiin')
// 検査実施 人数
summary.value = allCount
// 陽性者数 (累積)
summary.children[0].value = number
const summary = this.$store.state.patientsNotCruise
// console.log(summary, 'summary')
// 入院中
summary.children[0].children[0].value = number - taiin
// 軽症
summary.children[0].children[0].children[0].value = 0
// 重症
summary.children[0].children[0].children[1].value = 0
// 退院
summary.children[0].children[1].value = taiin
// 死亡
summary.children[0].children[2].value = dead
const confirmedCases = formatConfirmedCases(summary)
// console.log(confirmedCases, 'confirmedCases')
return confirmedCases
// 検査陽性者の状況
if (!summary) return formatConfirmedCases(Data.main_summary)
return summary
}
},
methods: {}
Expand Down
2 changes: 1 addition & 1 deletion pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default Vue.extend({
// },
async mounted() {
// 動的に最新情報を取得する
await sleep(100)
await sleep(3000)
await this.$store.dispatch('GET_BODIK_JSONP')
},
head(): MetaInfo {
Expand Down
4 changes: 4 additions & 0 deletions services/bodikApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ const nagasakiPrefectureConfirmedCasesId =
'de7ce61e-1849-47a1-b758-bca3f809cdf8'
const nagasakiCityNewsId = 'eb0ba50a-7a97-4029-9b75-9c6bab0568f6'

const aonyMouseId = '438f03f1-0ee8-466d-a5d9-e874f5367507'

export const fetchNagasakiPrefectureTestedCases = () =>
callFetchJsonp(baseUrl, nagasakiPrefectureTestedCasesId)
export const fetchNagasakiPrefectureConfirmedCases = () =>
callFetchJsonp(baseUrl, nagasakiPrefectureConfirmedCasesId)
export const fetchNagasakiCityNews = () =>
callFetchJsonp(baseUrl, nagasakiCityNewsId)

export const fetchonyMouseId = () => callFetchJsonp(baseUrl, aonyMouseId)

export const axiosNagasakiPrefectureTestedCases = axios =>
axios.$get(baseUrl + nagasakiPrefectureTestedCasesId)
export const axiosNagasakiPrefectureConfirmedCases = axios =>
Expand Down
40 changes: 28 additions & 12 deletions store/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// import axios from 'axios'
import { bodikApi } from '../services'
import { groupBy, reducer } from './util.js'
import { convertDateToSimpleFormat } from '@/utils/formatDate'

export const state = () => ({
allCount: 0,
testedNumber: [],
patients: [],
nagasakiCityNews: [],
attributes: [],
patientsNotCruise: [],
patientsGraphNotCruise: []
patientsNotCruise: null,
patientsGraphNotCruise: [],
otherData: []
})

export const getters = {
Expand All @@ -31,11 +30,7 @@ export const mutations = {
// 長崎県新型コロナウイルス感染症検査実施数のロード完了後の処理
setPrefectureTestedCases(state, data) {
if (!data || data.length === 0) return

state.testedNumber = data

// 検査件数の全数を取得
state.allCount = data.map(x => Number(x.件数)).reduce(reducer)
},

// 感染症陽性患者発表情報のロード完了後の処理
Expand All @@ -62,8 +57,11 @@ export const mutations = {
allDataUpdated(state, data) {
const data1 = data.data1
const data2 = data.data2
const data3 = data.data3
if (!data1 || !data2) return

state.otherData = data3

// state.groups = groupBy(data, r => r.公表_年月日)
const notCruise = data2.map(x => x).filter(date => date.クルーズ船 !== '1')
// console.log(notCruise, 'notCruise')
Expand All @@ -89,10 +87,25 @@ export const mutations = {
小計: groupsNotCruise[item] ? groupsNotCruise[item].length : 0
}
})
// console.log(state.patientsGraphNotCruise, 'state.patientsGraphNotCruise')

// 検査陽性者の状況
state.patientsNotCruise = notCruise
// 検査陽性者の状況のデータ作成
const 退院者数 = data3.filter(d => d.KEY === '県内_退院者数')
// console.log(退院者数, '退院者数')
const taiin = 退院者数 ? Number(退院者数[0].VALUE) : 0
// console.log(taiin, 'taiin')
// グラフ表示用のデータ作成
const formattedData = {
検査実施人数: data1.map(x => Number(x.件数)).reduce(reducer),
陽性者数: notCruise.length,
入院中: data2.length - taiin,
軽症中等症: 0,
重症: 0,
死亡: notCruise.filter(d => d.死亡フラグ === '1').length,
退院: taiin
}
// console.log(formattedData, 'formattedData')

state.patientsNotCruise = formattedData
}
}

Expand Down Expand Up @@ -127,10 +140,13 @@ export const actions = {
const news = await bodikApi.fetchNagasakiCityNews()
commit('setNagasakiCityNews', news.records)

const result3 = await bodikApi.fetchonyMouseId()

/// / 非同期データのロード後処理
commit('allDataUpdated', {
data1: result1.records,
data2: result2.records
data2: result2.records,
data3: result3.records
})
} catch (e) {}
}
Expand Down

0 comments on commit c69b892

Please sign in to comment.