Compare commits

...

12 Commits
8.0.0 ... 8.2.0

Author SHA1 Message Date
a0adcf0d1a Merge pull request #2437 from syuilo/develop
8.2.0
2018-08-24 05:38:18 +09:00
93b2b82993 8.2.0 2018-08-24 05:37:42 +09:00
4dee7d91b1 Better charts 2018-08-24 05:37:19 +09:00
59e2ed8ab0 Merge pull request #2435 from syuilo/master
Master
2018-08-24 03:48:05 +09:00
83790004dd 8.1.0 (#2426) (#2434)
* Update url-preview.vue

* 一時間ごとのグラフも見れるように

* Merge pull request #2423 from syuilo/develop (#2425)

* 8.1.0
2018-08-24 03:47:36 +09:00
efae7a7bce 8.1.0 (#2426)
* Update url-preview.vue

* 一時間ごとのグラフも見れるように

* Merge pull request #2423 from syuilo/develop (#2425)

* 8.1.0
2018-08-23 16:38:12 +09:00
e59f13e8ff Merge branch 'develop' of https://github.com/syuilo/misskey into develop 2018-08-23 16:37:40 +09:00
31ed8949b9 8.1.0 2018-08-23 16:37:32 +09:00
f1174a15e0 Merge pull request #2423 from syuilo/develop (#2425) 2018-08-23 16:37:07 +09:00
912ffae600 Merge pull request #2424 from acid-chicken/patch-4
Fix #2421
2018-08-23 16:36:42 +09:00
71a5662195 一時間ごとのグラフも見れるように 2018-08-23 16:36:23 +09:00
774834a31f Update url-preview.vue 2018-08-23 16:25:36 +09:00
13 changed files with 365 additions and 381 deletions

View File

@ -939,20 +939,20 @@ desktop/views/pages/admin/admin.unverify-user.vue:
unverify: "公式アカウントを解除する"
unverified: "公式アカウントを解除しました"
desktop/views/pages/admin/admin.notes-chart.vue:
title: "投稿"
local: "ローカル"
remote: "リモート"
desktop/views/pages/admin/admin.users-chart.vue:
title: "ユーザー"
local: "ローカル"
remote: "リモート"
desktop/views/pages/admin/admin.drive-chart.vue:
title: "ドライブ"
local: "ローカル"
remote: "リモート"
desktop/views/pages/admin/admin.chart.vue:
title: "チャート"
local-notes: "ローカルの投稿"
remote-notes: "リモートの投稿"
local-notes-total: "ローカルの投稿 (累計)"
remote-notes-total: "リモートの投稿 (累計)"
local-users: "ローカルのユーザー"
remote-users: "リモートのユーザー"
local-users-total: "ローカルのユーザー (累計)"
remote-users-total: "リモートのユーザー (累計)"
local-drive: "ローカルのドライブ使用量"
remote-drive: "リモートのドライブ使用量"
local-drive-total: "ローカルのドライブ使用量 (累計)"
remote-drive-total: "リモートのドライブ使用量 (累計)"
desktop/views/pages/deck/deck.tl-column.vue:
is-media-only: "メディア投稿のみ"

View File

@ -1,8 +1,8 @@
{
"name": "misskey",
"author": "syuilo <i@syuilo.com>",
"version": "8.0.0",
"clientVersion": "1.0.8790",
"version": "8.2.0",
"clientVersion": "1.0.8818",
"codename": "nighthike",
"main": "./built/index.js",
"private": true,
@ -89,6 +89,7 @@
"bootstrap-vue": "2.0.0-rc.11",
"cafy": "11.3.0",
"chalk": "2.4.1",
"chart.js": "2.7.2",
"commander": "2.17.1",
"crc-32": "1.2.0",
"css-loader": "1.0.0",
@ -206,6 +207,7 @@
"uuid": "3.3.2",
"v-animate-css": "0.0.2",
"vue": "2.5.17",
"vue-chartjs": "3.4.0",
"vue-cropperjs": "2.2.1",
"vue-js-modal": "1.3.18",
"vue-json-tree-view": "2.1.4",

View File

@ -176,7 +176,7 @@ export default Vue.extend({
</script>
<style lang="stylus" scoped>
.twitter
.player
position relative
width 100%

View File

@ -0,0 +1,40 @@
import Vue from 'vue';
import { Line } from 'vue-chartjs';
export default Vue.extend({
extends: Line,
props: {
data: {
required: true
},
opts: {
required: false
}
},
watch: {
data() {
this.render();
}
},
mounted() {
this.render();
},
methods: {
render() {
this.renderChart(this.data, Object.assign({
responsive: false,
scales: {
xAxes: [{
type: 'time',
time: {
displayFormats: {
quarter: 'YYYY/MM/D h:mm'
}
},
distribution: 'series'
}]
}
}, this.opts || {}));
}
}
});

View File

@ -0,0 +1,195 @@
<template>
<div class="card gkgckalzgidaygcxnugepioremxvxvpt">
<header>
<b>%i18n:@title%:</b>
<select v-model="chartType">
<option value="local-users">%i18n:@local-users%</option>
<option value="remote-users">%i18n:@remote-users%</option>
<option value="local-users-total">%i18n:@local-users-total%</option>
<option value="remote-users-total">%i18n:@remote-users-total%</option>
<option value="local-notes">%i18n:@local-notes%</option>
<option value="remote-notes">%i18n:@remote-notes%</option>
<option value="local-notes-total">%i18n:@local-notes-total%</option>
<option value="remote-notes-total">%i18n:@remote-notes-total%</option>
<option value="local-drive">%i18n:@local-drive%</option>
<option value="remote-drive">%i18n:@remote-drive%</option>
<option value="local-drive-total">%i18n:@local-drive-total%</option>
<option value="remote-drive-total">%i18n:@remote-drive-total%</option>
</select>
<div>
<a @click="span = 'day'">Per DAY</a> | <a @click="span = 'hour'">Per HOUR</a>
</div>
</header>
<x-chart v-if="chart" :data="data[0]" :opts="data[1]" :width="720" :height="300"/>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import XChart from './admin.chart.chart.ts';
export default Vue.extend({
components: {
XChart
},
props: {
chart: {
required: true
}
},
data() {
return {
chartType: 'local-notes',
span: 'hour'
};
},
computed: {
data(): any {
if (this.chart == null) return null;
switch (this.chartType) {
case 'local-users': return this.usersChart(true, false);
case 'remote-users': return this.usersChart(false, false);
case 'local-users-total': return this.usersChart(true, true);
case 'remote-users-total': return this.usersChart(false, true);
case 'local-notes': return this.notesChart(true);
case 'remote-notes': return this.notesChart(false);
case 'local-notes-total': return this.notesTotalChart(true);
case 'remote-notes-total': return this.notesTotalChart(false);
case 'local-drive': return this.driveChart(true, false);
case 'remote-drive': return this.driveChart(false, false);
case 'local-drive-total': return this.driveChart(true, true);
case 'remote-drive-total': return this.driveChart(false, true);
}
},
stats(): any[] {
return (
this.span == 'day' ? this.chart.perDay :
this.span == 'hour' ? this.chart.perHour :
null
);
}
},
methods: {
notesChart(local: boolean): any {
const data = this.stats.slice().reverse().map(x => ({
date: new Date(x.date),
normal: local ? x.notes.local.diffs.normal : x.notes.remote.diffs.normal,
reply: local ? x.notes.local.diffs.reply : x.notes.remote.diffs.reply,
renote: local ? x.notes.local.diffs.renote : x.notes.remote.diffs.renote,
total: local ? x.notes.local.diff : x.notes.remote.diff
}));
return [{
datasets: [{
label: 'Normal',
fill: false,
borderColor: '#41ddde',
borderWidth: 2,
pointBackgroundColor: '#fff',
lineTension: 0,
data: data.map(x => ({ t: x.date, y: x.normal }))
}, {
label: 'Replies',
fill: false,
borderColor: '#f7796c',
borderWidth: 2,
pointBackgroundColor: '#fff',
lineTension: 0,
data: data.map(x => ({ t: x.date, y: x.reply }))
}, {
label: 'Renotes',
fill: false,
borderColor: '#a1de41',
borderWidth: 2,
pointBackgroundColor: '#fff',
lineTension: 0,
data: data.map(x => ({ t: x.date, y: x.renote }))
}]
}];
},
notesTotalChart(local: boolean): any {
const data = this.stats.slice().reverse().map(x => ({
date: new Date(x.date),
count: local ? x.notes.local.total : x.notes.remote.total,
}));
return [{
datasets: [{
label: local ? 'Local Notes' : 'Remote Notes',
fill: false,
borderColor: '#f6584f',
borderWidth: 2,
pointBackgroundColor: '#fff',
lineTension: 0,
data: data.map(x => ({ t: x.date, y: x.count }))
}]
}];
},
usersChart(local: boolean, total: boolean): any {
const data = this.stats.slice().reverse().map(x => ({
date: new Date(x.date),
count: local ?
total ? x.users.local.total : x.users.local.diff :
total ? x.users.remote.total : x.users.remote.diff
}));
return [{
datasets: [{
label: local ? 'Local Users' : 'Remote Users',
fill: false,
borderColor: '#f6584f',
borderWidth: 2,
pointBackgroundColor: '#fff',
lineTension: 0,
data: data.map(x => ({ t: x.date, y: x.count }))
}]
}];
},
driveChart(local: boolean, total: boolean): any {
const data = this.stats.slice().reverse().map(x => ({
date: new Date(x.date),
count: local ?
total ? x.drive.local.totalSize : x.drive.local.diffSize :
total ? x.drive.remote.totalSize : x.drive.remote.diffSize
}));
return [{
datasets: [{
label: local ? 'Local Drive Usage' : 'Remote Drive Usage',
fill: false,
borderColor: '#f6584f',
borderWidth: 2,
pointBackgroundColor: '#fff',
lineTension: 0,
data: data.map(x => ({ t: x.date, y: x.count }))
}]
}, {
scales: {
yAxes: [{
ticks: {
callback: (value) => {
return Vue.filter('bytes')(value);
}
}
}]
}
}];
}
}
});
</script>
<style lang="stylus" scoped>
@import '~const.styl'
.gkgckalzgidaygcxnugepioremxvxvpt
> header
display flex
> b
margin-right 8px
> *:last-child
margin-left auto
</style>

View File

@ -1,51 +0,0 @@
<template>
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`">
<polyline
:points="points"
fill="none"
stroke-width="1"
stroke="#555"/>
</svg>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: {
chart: {
required: true
},
type: {
type: String,
required: true
}
},
data() {
return {
viewBoxX: 365,
viewBoxY: 70,
points: null
};
},
created() {
const peak = Math.max.apply(null, this.chart.map(d => this.type == 'local' ? d.drive.local.totalSize : d.drive.remote.totalSize));
if (peak != 0) {
const data = this.chart.slice().reverse().map(x => ({
size: this.type == 'local' ? x.drive.local.totalSize : x.drive.remote.totalSize
}));
this.points = data.map((d, i) => `${i},${(1 - (d.size / peak)) * this.viewBoxY}`).join(' ');
}
}
});
</script>
<style lang="stylus" scoped>
svg
display block
padding 10px
width 100%
</style>

View File

@ -1,34 +0,0 @@
<template>
<div class="card">
<header>%i18n:@title%</header>
<div class="card">
<header>%i18n:@local%</header>
<x-chart v-if="chart" :chart="chart" type="local"/>
</div>
<div class="card">
<header>%i18n:@remote%</header>
<x-chart v-if="chart" :chart="chart" type="remote"/>
</div>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import XChart from "./admin.drive-chart.chart.vue";
export default Vue.extend({
components: {
XChart
},
props: {
chart: {
required: true
}
}
});
</script>
<style lang="stylus" scoped>
@import '~const.styl'
</style>

View File

@ -1,76 +0,0 @@
<template>
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`">
<polyline
:points="pointsNote"
fill="none"
stroke-width="1"
stroke="#41ddde"/>
<polyline
:points="pointsReply"
fill="none"
stroke-width="1"
stroke="#f7796c"/>
<polyline
:points="pointsRenote"
fill="none"
stroke-width="1"
stroke="#a1de41"/>
<polyline
:points="pointsTotal"
fill="none"
stroke-width="1"
stroke="#555"
stroke-dasharray="2 2"/>
</svg>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: {
chart: {
required: true
},
type: {
type: String,
required: true
}
},
data() {
return {
viewBoxX: 365,
viewBoxY: 70,
pointsNote: null,
pointsReply: null,
pointsRenote: null,
pointsTotal: null
};
},
created() {
const peak = Math.max.apply(null, this.chart.map(d => this.type == 'local' ? d.notes.local.diff : d.notes.remote.diff));
if (peak != 0) {
const data = this.chart.slice().reverse().map(x => ({
normal: this.type == 'local' ? x.notes.local.diffs.normal : x.notes.remote.diffs.normal,
reply: this.type == 'local' ? x.notes.local.diffs.reply : x.notes.remote.diffs.reply,
renote: this.type == 'local' ? x.notes.local.diffs.renote : x.notes.remote.diffs.renote,
total: this.type == 'local' ? x.notes.local.diff : x.notes.remote.diff
}));
this.pointsNote = data.map((d, i) => `${i},${(1 - (d.normal / peak)) * this.viewBoxY}`).join(' ');
this.pointsReply = data.map((d, i) => `${i},${(1 - (d.reply / peak)) * this.viewBoxY}`).join(' ');
this.pointsRenote = data.map((d, i) => `${i},${(1 - (d.renote / peak)) * this.viewBoxY}`).join(' ');
this.pointsTotal = data.map((d, i) => `${i},${(1 - (d.total / peak)) * this.viewBoxY}`).join(' ');
}
}
});
</script>
<style lang="stylus" scoped>
svg
display block
padding 10px
width 100%
</style>

View File

@ -1,34 +0,0 @@
<template>
<div class="card">
<header>%i18n:@title%</header>
<div class="card">
<header>%i18n:@local%</header>
<x-chart v-if="chart" :chart="chart" type="local"/>
</div>
<div class="card">
<header>%i18n:@remote%</header>
<x-chart v-if="chart" :chart="chart" type="remote"/>
</div>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import XChart from "./admin.notes-chart.chart.vue";
export default Vue.extend({
components: {
XChart
},
props: {
chart: {
required: true
}
}
});
</script>
<style lang="stylus" scoped>
@import '~const.styl'
</style>

View File

@ -1,51 +0,0 @@
<template>
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`">
<polyline
:points="points"
fill="none"
stroke-width="1"
stroke="#555"/>
</svg>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: {
chart: {
required: true
},
type: {
type: String,
required: true
}
},
data() {
return {
viewBoxX: 365,
viewBoxY: 70,
points: null
};
},
created() {
const peak = Math.max.apply(null, this.chart.map(d => this.type == 'local' ? d.users.local.diff : d.users.remote.diff));
if (peak != 0) {
const data = this.chart.slice().reverse().map(x => ({
count: this.type == 'local' ? x.users.local.diff : x.users.remote.diff
}));
this.points = data.map((d, i) => `${i},${(1 - (d.count / peak)) * this.viewBoxY}`).join(' ');
}
}
});
</script>
<style lang="stylus" scoped>
svg
display block
padding 10px
width 100%
</style>

View File

@ -1,34 +0,0 @@
<template>
<div class="card">
<header>%i18n:@title%</header>
<div class="card">
<header>%i18n:@local%</header>
<x-chart v-if="chart" :chart="chart" type="local"/>
</div>
<div class="card">
<header>%i18n:@remote%</header>
<x-chart v-if="chart" :chart="chart" type="remote"/>
</div>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import XChart from "./admin.users-chart.chart.vue";
export default Vue.extend({
components: {
XChart
},
props: {
chart: {
required: true
}
}
});
</script>
<style lang="stylus" scoped>
@import '~const.styl'
</style>

View File

@ -11,9 +11,7 @@
<main>
<div v-show="page == 'dashboard'">
<x-dashboard/>
<x-users-chart :chart="chart"/>
<x-notes-chart :chart="chart"/>
<x-drive-chart :chart="chart"/>
<x-chart :chart="chart"/>
</div>
<div v-if="page == 'users'">
<x-suspend-user/>
@ -34,9 +32,7 @@ import XSuspendUser from "./admin.suspend-user.vue";
import XUnsuspendUser from "./admin.unsuspend-user.vue";
import XVerifyUser from "./admin.verify-user.vue";
import XUnverifyUser from "./admin.unverify-user.vue";
import XUsersChart from "./admin.users-chart.vue";
import XNotesChart from "./admin.notes-chart.vue";
import XDriveChart from "./admin.drive-chart.vue";
import XChart from "./admin.chart.vue";
export default Vue.extend({
components: {
@ -45,9 +41,7 @@ export default Vue.extend({
XUnsuspendUser,
XVerifyUser,
XUnverifyUser,
XUsersChart,
XNotesChart,
XDriveChart
XChart
},
data() {
return {

View File

@ -8,96 +8,129 @@ export const meta = {
};
export default (params: any) => new Promise(async (res, rej) => {
const daysRange = 90;
const hoursRange = 24;
const now = new Date();
const y = now.getFullYear();
const m = now.getMonth();
const d = now.getDate();
const h = now.getHours();
const stats = await Stats.find({
span: 'day',
date: {
$gt: new Date(y - 1, m, d)
}
}, {
sort: {
date: -1
},
fields: {
_id: 0
}
});
const [statsPerDay, statsPerHour] = await Promise.all([
Stats.find({
span: 'day',
date: {
$gt: new Date(y, m, d - daysRange)
}
}, {
sort: {
date: -1
},
fields: {
_id: 0
}
}),
Stats.find({
span: 'hour',
date: {
$gt: new Date(y, m, d, h - hoursRange)
}
}, {
sort: {
date: -1
},
fields: {
_id: 0
}
}),
]);
const chart: Array<Omit<IStats, '_id'>> = [];
const format = (src: IStats[], span: 'day' | 'hour') => {
const chart: Array<Omit<Omit<IStats, '_id'>, 'span'>> = [];
for (let i = 364; i >= 0; i--) {
const day = new Date(y, m, d - i);
const range =
span == 'day' ? daysRange :
span == 'hour' ? hoursRange :
null;
const stat = stats.find(s => s.date.getTime() == day.getTime());
for (let i = (range - 1); i >= 0; i--) {
const current =
span == 'day' ? new Date(y, m, d - i) :
span == 'hour' ? new Date(y, m, d, h - i) :
null;
if (stat) {
chart.unshift(stat);
} else { // 隙間埋め
const mostRecent = stats.find(s => s.date.getTime() < day.getTime());
if (mostRecent) {
chart.unshift(Object.assign({}, mostRecent, {
date: day
}));
} else {
chart.unshift({
date: day,
span: 'day',
users: {
local: {
total: 0,
diff: 0
},
remote: {
total: 0,
diff: 0
}
},
notes: {
local: {
total: 0,
diff: 0,
diffs: {
normal: 0,
reply: 0,
renote: 0
const stat = src.find(s => s.date.getTime() == current.getTime());
if (stat) {
chart.unshift(stat);
} else { // 隙間埋め
const mostRecent = src.find(s => s.date.getTime() < current.getTime());
if (mostRecent) {
chart.unshift(Object.assign({}, mostRecent, {
date: current
}));
} else {
chart.unshift({
date: current,
users: {
local: {
total: 0,
diff: 0
},
remote: {
total: 0,
diff: 0
}
},
remote: {
total: 0,
diff: 0,
diffs: {
normal: 0,
reply: 0,
renote: 0
notes: {
local: {
total: 0,
diff: 0,
diffs: {
normal: 0,
reply: 0,
renote: 0
}
},
remote: {
total: 0,
diff: 0,
diffs: {
normal: 0,
reply: 0,
renote: 0
}
}
},
drive: {
local: {
totalCount: 0,
totalSize: 0,
diffCount: 0,
diffSize: 0
},
remote: {
totalCount: 0,
totalSize: 0,
diffCount: 0,
diffSize: 0
}
}
},
drive: {
local: {
totalCount: 0,
totalSize: 0,
diffCount: 0,
diffSize: 0
},
remote: {
totalCount: 0,
totalSize: 0,
diffCount: 0,
diffSize: 0
}
}
});
});
}
}
}
}
chart.forEach(x => {
delete x.date;
chart.forEach(x => {
delete (x as any).span;
});
return chart;
};
res({
perDay: format(statsPerDay, 'day'),
perHour: format(statsPerHour, 'hour')
});
res(chart);
});