mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-23 04:34:15 -04:00
[admin][stats] flags
This commit is contained in:
parent
605b70dbc0
commit
1befacb480
29
components/ListExpandable.vue
Normal file
29
components/ListExpandable.vue
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<template>
|
||||||
|
<ul class="list-unstyled">
|
||||||
|
<li v-for="(value, key, i) in data" v-if="expanded || i < 10">
|
||||||
|
<slot v-bind:k="k" v-bind:v="v">
|
||||||
|
<strong>{{key}}</strong>: {{value}}
|
||||||
|
</slot>
|
||||||
|
</li>
|
||||||
|
<li v-if="!expanded">
|
||||||
|
<a href="#" @click.prevent="expanded = true">
|
||||||
|
<T>table.more</T>
|
||||||
|
<Icon v="caret-down"/>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
data: { required: true },
|
||||||
|
initial: { default: 10, },
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
expanded: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -424,6 +424,7 @@ table:
|
|||||||
count: 'Count'
|
count: 'Count'
|
||||||
sort: 'Drag to sort'
|
sort: 'Drag to sort'
|
||||||
scrollUp: 'Scroll to the top'
|
scrollUp: 'Scroll to the top'
|
||||||
|
more: 'Show more'
|
||||||
|
|
||||||
api:
|
api:
|
||||||
header: 'Public API'
|
header: 'Public API'
|
||||||
|
@ -798,6 +798,7 @@ table:
|
|||||||
count: 'Liczba'
|
count: 'Liczba'
|
||||||
sort: 'Przeciągnij by posortować'
|
sort: 'Przeciągnij by posortować'
|
||||||
scrollUp: 'Przewiń na samą górę'
|
scrollUp: 'Przewiń na samą górę'
|
||||||
|
more: 'Pokaż więcej'
|
||||||
|
|
||||||
api:
|
api:
|
||||||
header: 'Publiczne API'
|
header: 'Publiczne API'
|
||||||
|
@ -86,11 +86,14 @@
|
|||||||
<Icon v="tags"/>
|
<Icon v="tags"/>
|
||||||
Pronouns
|
Pronouns
|
||||||
</h4>
|
</h4>
|
||||||
<ul class="list-unstyled">
|
<ListExpandable :data="locale.pronouns"/>
|
||||||
<li v-for="(count, pronoun) in locale.pronouns" v-if="count >= 10">
|
</div>
|
||||||
<strong>{{pronoun}}</strong>: {{count}}
|
<div class="flex-grow-1">
|
||||||
</li>
|
<h4 class="h5">
|
||||||
</ul>
|
<Icon v="flag"/>
|
||||||
|
Flags
|
||||||
|
</h4>
|
||||||
|
<ListExpandable :data="locale.flags"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-grow-1">
|
<div class="flex-grow-1">
|
||||||
<h4 class="h5">
|
<h4 class="h5">
|
||||||
@ -118,7 +121,9 @@
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return { socialProviders }
|
return {
|
||||||
|
socialProviders,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async asyncData({ app, store }) {
|
async asyncData({ app, store }) {
|
||||||
if (!store.state.user || store.state.user.roles !== 'admin') {
|
if (!store.state.user || store.state.user.roles !== 'admin') {
|
||||||
|
@ -59,8 +59,9 @@ router.get('/admin/stats', async (req, res) => {
|
|||||||
const locales = {};
|
const locales = {};
|
||||||
for (let locale in req.locales) {
|
for (let locale in req.locales) {
|
||||||
if (!req.locales.hasOwnProperty(locale)) { continue; }
|
if (!req.locales.hasOwnProperty(locale)) { continue; }
|
||||||
const profiles = await req.db.all(SQL`SELECT pronouns FROM profiles WHERE locale=${locale}`);
|
const profiles = await req.db.all(SQL`SELECT pronouns, flags FROM profiles WHERE locale=${locale}`);
|
||||||
const pronouns = {}
|
const pronouns = {}
|
||||||
|
const flags = {}
|
||||||
for (let profile of profiles) {
|
for (let profile of profiles) {
|
||||||
const pr = JSON.parse(profile.pronouns);
|
const pr = JSON.parse(profile.pronouns);
|
||||||
for (let pronoun in pr) {
|
for (let pronoun in pr) {
|
||||||
@ -75,6 +76,14 @@ router.get('/admin/stats', async (req, res) => {
|
|||||||
}
|
}
|
||||||
pronouns[p] += pr[pronoun] === 1 ? 1 : 0.5;
|
pronouns[p] += pr[pronoun] === 1 ? 1 : 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fl = JSON.parse(profile.flags);
|
||||||
|
for (let flag of fl) {
|
||||||
|
if (flags[flag] === undefined) {
|
||||||
|
flags[flag] = 0;
|
||||||
|
}
|
||||||
|
flags[flag] += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
locales[locale] = {
|
locales[locale] = {
|
||||||
@ -82,6 +91,7 @@ router.get('/admin/stats', async (req, res) => {
|
|||||||
url: req.locales[locale].url,
|
url: req.locales[locale].url,
|
||||||
profiles: profiles.length,
|
profiles: profiles.length,
|
||||||
pronouns: sortByValue(pronouns, true),
|
pronouns: sortByValue(pronouns, true),
|
||||||
|
flags: sortByValue(flags, true),
|
||||||
nouns: {
|
nouns: {
|
||||||
approved: (await req.db.get(SQL`SELECT count(*) AS c FROM nouns WHERE locale=${locale} AND approved=1`)).c,
|
approved: (await req.db.get(SQL`SELECT count(*) AS c FROM nouns WHERE locale=${locale} AND approved=1`)).c,
|
||||||
awaiting: (await req.db.get(SQL`SELECT count(*) AS c FROM nouns WHERE locale=${locale} AND approved=0`)).c,
|
awaiting: (await req.db.get(SQL`SELECT count(*) AS c FROM nouns WHERE locale=${locale} AND approved=0`)).c,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user