Skip to content

Commit

Permalink
fix(status): fix group info
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Mar 13, 2021
1 parent db6f808 commit 593f3e9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/plugin-status/client/components/group-chart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const option = computed(() => ({
trigger: 'item',
formatter({ data, value }) {
const output = [data.name]
output.push(`平台:${data.platform}`)
if (data.memberCount) output.push(`人数:${data.memberCount}`)
if (data.assignee) output.push(`接入:${data.assignee}`)
output.push(`日均发言:${+value.toFixed(1)}`)
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-status/server/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ declare module 'koishi-core' {

interface Database {
getActiveData(): Promise<ActiveData>
getStatsData(): Promise<Synchronizer.Data>
setChannels(data: Partial<Channel>[]): Promise<void>
Synchronizer: new (db: Database) => Synchronizer
}
Expand Down
8 changes: 2 additions & 6 deletions packages/plugin-status/server/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,13 @@ Database.extend('koishi-plugin-mysql', {
async upload(date: Date): Promise<void> {
const dateString = date.toLocaleDateString('zh-CN')
const hourString = `${dateString}-${date.getHours()}:00`
const updateNumber = Time.getDateNumber(date)
const sqls: string[] = []
this._hourly.synchronize(hourString, sqls)
this._daily.synchronize(dateString, sqls)
this._longterm.synchronize(dateString, sqls)
for (const id in this.groups) {
sqls.push(`
UPDATE \`channel\` SET
\`activity\` = JSON_SET(\`activity\`, '$."${updateNumber}"', IFNULL(JSON_EXTRACT(\`activity\`, '$."${updateNumber}"'), 0) + ${this.groups[id]})
WHERE \`id\` = '${id}'
`)
const update = Stat.Recorded.prototype.update('activity', { [Time.getDateNumber(date)]: this.groups[id] })
sqls.push(`UPDATE \`channel\` SET ${update} WHERE \`id\` = '${id}'`)
delete this.groups[id]
}
if (!sqls.length) return
Expand Down
5 changes: 3 additions & 2 deletions packages/plugin-status/server/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ async function download(ctx: Context, date: string) {
const updateList: Pick<Channel, 'id' | 'name'>[] = []

async function getGroupInfo(bot: Bot) {
const { platform } = bot
const groups = await bot.getGroupList()
for (const { groupId, groupName: name } of groups) {
const id = `${bot.platform}:${groupId}`
Expand All @@ -88,10 +89,10 @@ async function download(ctx: Context, date: string) {
if (name !== oldName) updateList.push({ id, name })
extension.groups.push({
name,
platform: bot.platform,
platform,
assignee,
value: messageMap[id],
last: daily[0].group[id],
assignee: ctx.bots[assignee].selfId,
})
}
}
Expand Down

0 comments on commit 593f3e9

Please sign in to comment.