-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #326 from globe-and-citizen/develop
Release 1.8
- Loading branch information
Showing
16 changed files
with
2,918 additions
and
1,532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<template> | ||
<TheHeader feedbackButton title="Stats" /> | ||
<q-page-container style="max-width: none"> | ||
<q-page> | ||
<q-table | ||
class="q-ma-md" | ||
:columns="columnsSummary" | ||
hide-bottom | ||
:pagination="pagination" | ||
:rows="rowSummary" | ||
:title="`Summary Data: ${visitors === 1 ? '1 visitor' : `${visitors} visitors`}`" | ||
/> | ||
<q-table | ||
class="q-ma-md" | ||
:columns="columnsDetailed" | ||
hide-bottom | ||
:pagination="pagination" | ||
:rows="statStore.getStats" | ||
:title="`Detailed Data: ${visits === 1 ? '1 visit' : `${visits} visits`}`" | ||
/> | ||
</q-page> | ||
</q-page-container> | ||
</template> | ||
|
||
<script setup> | ||
import TheHeader from 'src/components/shared/TheHeader.vue' | ||
import { useEntryStore, useStatStore } from 'src/stores' | ||
import { shortMonthDayTime } from 'src/utils/date' | ||
import { computed, onMounted } from 'vue' | ||
import { useRouter } from 'vue-router' | ||
const router = useRouter() | ||
const entryStore = useEntryStore() | ||
const statStore = useStatStore() | ||
const fields = { | ||
clicks: { label: 'Clicks' }, | ||
keypresses: { label: 'Keypresses' }, | ||
mouseMovements: { label: 'Mouse Movements' }, | ||
scrolls: { label: 'Scrolls' }, | ||
totalTime: { label: 'Time Spent' } | ||
} | ||
const columnsDetailed = [ | ||
{ name: 'created', align: 'center', label: 'Date', field: (row) => shortMonthDayTime(row.created), sortable: true }, | ||
...Object.keys(fields).map((fieldName) => ({ name: fieldName, label: fields[fieldName].label, field: fieldName, sortable: true })) | ||
] | ||
const columnsSummary = [ | ||
{ name: 'type', align: 'center', label: '', field: 'type', sortable: true }, | ||
...Object.keys(fields).map((fieldName) => ({ name: fieldName, label: fields[fieldName].label, field: fieldName, sortable: true })) | ||
] | ||
const entry = computed(() => entryStore.getEntries?.find((entry) => router.currentRoute.value.href.includes(entry.slug))) | ||
const pagination = { sortBy: 'date', descending: true, rowsPerPage: 0 } | ||
const visits = computed(() => statStore.getStats?.length || 0) | ||
const visitors = computed(() => { | ||
const authorIds = new Set(statStore.getStats?.map((stat) => stat.author.id)) | ||
return authorIds.size | ||
}) | ||
const rowSummary = computed(() => { | ||
const stats = statStore.getStats | ||
if (!stats || stats.length === 0) { | ||
return [] | ||
} | ||
const averageRow = { type: 'Average' } | ||
const totalRow = { type: 'Total' } | ||
Object.keys(fields).forEach((field) => { | ||
averageRow[field] = (stats.reduce((acc, stat) => acc + stat[field], 0) / stats.length).toFixed(1) | ||
totalRow[field] = stats.reduce((acc, stat) => acc + stat[field], 0) | ||
}) | ||
return [averageRow, totalRow] | ||
}) | ||
onMounted(async () => { | ||
if (!entryStore.getEntries.length) { | ||
await entryStore.fetchEntries() | ||
} | ||
await statStore.fetchStats('entries', entry.value.id) | ||
}) | ||
</script> |
Oops, something went wrong.