🚧 wip: stats
All checks were successful
repod / xml (push) Successful in 2m15s
repod / php (push) Successful in 1m1s
repod / nodejs (push) Successful in 3m4s
repod / release (push) Has been skipped

This commit is contained in:
Michel Roux 2024-02-20 21:16:11 +01:00
parent 5e7b6566e6
commit 399d2d7496

View File

@ -1,12 +1,15 @@
<template>
<AppContent>
<Loading />
<Loading v-if="loading" />
</AppContent>
</template>
<script>
import AppContent from '../components/Atoms/AppContent.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 {
name: 'Statistics',
@ -14,5 +17,35 @@ export default {
AppContent,
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>