WIP: stats #62

Closed
Xefir wants to merge 6 commits from stats into main
Showing only changes of commit 399d2d7496 - Show all commits

View File

@ -1,12 +1,15 @@
<template> <template>
<AppContent> <AppContent>
<Loading /> <Loading v-if="loading" />
</AppContent> </AppContent>
</template> </template>
<script> <script>
import AppContent from '../components/Atoms/AppContent.vue' import AppContent from '../components/Atoms/AppContent.vue'
import Loading from '../components/Atoms/Loading.vue' import Loading from '../components/Atoms/Loading.vue'
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import { showError } from '@nextcloud/dialogs'
export default { export default {
name: 'Statistics', name: 'Statistics',
@ -14,5 +17,35 @@ export default {
AppContent, AppContent,
Loading, Loading,
}, },
data() {
return {
loading: true,
since: 0,
stats: [],
}
},
mounted() {
this.fetchData()
},
methods: {
async fetchData() {
try {
this.loading = true
const stats = []
const episodes = await axios.get(generateUrl('/apps/gpoddersync/episode_action?since={since}', { since: this.since }))
for (const action of episodes.data) {
if (action.position > 0) {
stats[action.podcast] += action.position
}
}
this.stats = stats
} catch (e) {
console.error(e)
showError(t('repod', 'Error while fetching the statistics'))
} finally {
this.loading = false
}
},
},
} }
</script> </script>