Skip to content

Commit

Permalink
fix(analytics): add data length to avoid mysql index error
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Dec 18, 2023
1 parent 3c6a948 commit 4fe9615
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion plugins/analytics/client/numbers/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="card-grid numeric-grid" v-if="store.analytics">
<k-slot name="analytic-number" :component="Numeric">
<k-slot name="analytic-number">
<k-slot-item>
<numeric icon="analytic:user" title="用户数量">
<template #default>{{ store.analytics.userCount }}</template>
Expand Down
2 changes: 1 addition & 1 deletion plugins/analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@koishijs/plugin-analytics",
"description": "Show statistics for Koishi application",
"version": "2.0.0",
"version": "2.0.1",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
Expand Down
15 changes: 8 additions & 7 deletions plugins/analytics/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class Analytics extends DataService<Analytics.Payload> {
ctx.model.extend('analytics.message', {
date: 'integer',
hour: 'integer',
type: 'string',
selfId: 'string',
platform: 'string',
type: 'string(63)',
selfId: 'string(63)',
platform: 'string(63)',
count: 'integer',
}, {
primary: ['date', 'hour', 'type', 'selfId', 'platform'],
Expand All @@ -52,11 +52,11 @@ class Analytics extends DataService<Analytics.Payload> {
ctx.model.extend('analytics.command', {
date: 'integer',
hour: 'integer',
name: 'string',
selfId: 'string',
name: 'string(63)',
selfId: 'string(63)',
userId: 'integer',
channelId: 'string',
platform: 'string',
channelId: 'string(63)',
platform: 'string(63)',
count: 'integer',
}, {
primary: ['date', 'hour', 'name', 'selfId', 'userId', 'channelId', 'platform'],
Expand Down Expand Up @@ -87,6 +87,7 @@ class Analytics extends DataService<Analytics.Payload> {
})

ctx.any().before('command/execute', ({ command, session }) => {
if (session.bot.hidden) return
this.addAudit(this.commands, {
...this.createIndex(session),
name: command.name,
Expand Down

0 comments on commit 4fe9615

Please sign in to comment.