added analytics for spider

This commit is contained in:
Marvin Zhang
2019-04-28 13:17:40 +08:00
parent 7b61a20324
commit a9f59dc110
10 changed files with 304 additions and 137 deletions

View File

@@ -14,7 +14,16 @@ const state = {
importForm: {
url: '',
type: 'github'
}
},
// spider overview stats
overviewStats: {},
// spider status stats
statusStats: [],
// spider daily stats
dailyStats: []
}
const getters = {}
@@ -31,6 +40,15 @@ const mutations = {
},
SET_IMPORT_FORM (state, value) {
state.importForm = value
},
SET_OVERVIEW_STATS (state, value) {
state.overviewStats = value
},
SET_STATUS_STATS (state, value) {
state.statusStats = value
},
SET_DAILY_STATS (state, value) {
state.dailyStats = value
}
}
@@ -138,6 +156,14 @@ const actions = {
.then(response => {
console.log(response)
})
},
getSpiderStats ({ state, commit }) {
return request.get('/stats/get_spider_stats?spider_id=' + state.spiderForm._id)
.then(response => {
commit('SET_OVERVIEW_STATS', response.data.overview)
commit('SET_STATUS_STATS', response.data.task_count_by_status)
commit('SET_DAILY_STATS', response.data.daily_stats)
})
}
}