Skip to content

Commit

Permalink
style: 放错地方了
Browse files Browse the repository at this point in the history
  • Loading branch information
XasYer committed Dec 27, 2024
1 parent 10a0941 commit 921cd3f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 46 deletions.
45 changes: 0 additions & 45 deletions apps/help.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import _ from 'lodash'
import { redis } from '#lib'
import { help as helpUtil } from '#models'
import { App, Render, Version } from '#components'
import moment from 'moment'

const appInfo = {
id: 'help',
Expand All @@ -13,49 +11,6 @@ const rule = {
help: {
reg: App.getReg('(插件|plugin)?(帮助|菜单|help)'),
fnc: help
},
apiStats: {
reg: App.getReg('api(调用)?统计'),
fnc: async e => {
const data = []
for (let i = 0; i >= -1; i--) {
const now = moment().add(i, 'days').format('YYYY-MM-DD')
const apis = []
let cursor = 0
do {
const res = await redis.scan(cursor, { MATCH: `steam-plugin:api:${now}:*`, COUNT: 10000 })
cursor = res.cursor
for (const key of res.keys) {
const v = Number(await redis.get(key))
apis.push({ name: key.split(':').pop(), v })
}
} while (cursor != 0)
if (apis.length) {
const total = _.sumBy(apis, 'v')
data.push({
title: `${now} api调用统计`,
desc: `共${total}次`,
games: _.orderBy(apis, 'v', 'desc').map(i => {
const percent = (i.v / total * 100).toFixed(0) + '%'
return {
name: i.name,
appid: percent,
appidStyle: `style="background-color: #999999; width: ${percent};"`,
desc: `${i.v}次`,
noImg: true
}
})
})
}
}
if (!data.length) {
await e.reply('还没有api调用统计数据哦')
return true
}
const img = await Render.render('inventory/index', { data })
await e.reply(img)
return true
}
}
// version: {
// reg: /^#?steam(插件|plugin)?(版本|version)$/i,
Expand Down
48 changes: 47 additions & 1 deletion apps/stats.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Render, App, Config } from '#components'
import _ from 'lodash'
import moment from 'moment'
import { redis } from '#lib'
import { db, utils } from '#models'
import { Render, App, Config } from '#components'

const appInfo = {
id: 'stats',
Expand Down Expand Up @@ -106,6 +109,49 @@ const rule = {
return true
}

const img = await Render.render('inventory/index', { data })
await e.reply(img)
return true
}
},
apiStats: {
reg: App.getReg('api(调用)?统计'),
fnc: async e => {
const data = []
for (let i = 0; i >= -1; i--) {
const now = moment().add(i, 'days').format('YYYY-MM-DD')
const apis = []
let cursor = 0
do {
const res = await redis.scan(cursor, { MATCH: `steam-plugin:api:${now}:*`, COUNT: 10000 })
cursor = res.cursor
for (const key of res.keys) {
const v = Number(await redis.get(key))
apis.push({ name: key.split(':').pop(), v })
}
} while (cursor != 0)
if (apis.length) {
const total = _.sumBy(apis, 'v')
data.push({
title: `${now} api调用统计`,
desc: `共${total}次`,
games: _.orderBy(apis, 'v', 'desc').map(i => {
const percent = (i.v / total * 100).toFixed(0) + '%'
return {
name: i.name,
appid: percent,
appidStyle: `style="background-color: #999999; width: ${percent};"`,
desc: `${i.v}次`,
noImg: true
}
})
})
}
}
if (!data.length) {
await e.reply('还没有api调用统计数据哦')
return true
}
const img = await Render.render('inventory/index', { data })
await e.reply(img)
return true
Expand Down

0 comments on commit 921cd3f

Please sign in to comment.