Skip to content

Commit

Permalink
fix(webui): check unknown columns, fix #248
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Apr 27, 2021
1 parent b56c4a3 commit 2a0bbfb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/plugin-webui/src/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ abstract class Stat<K extends string, V> {
synchronize(date: string, sqls: string[]) {
const updates: string[] = []
for (const name in this.data) {
if (!this.fields.includes(name)) {
logger.warn(new Error(`unknown key "${name}" in stats table "${this.table}"`))
delete this.data[name]
continue
}
const update = this.update(name, this.data[name])
if (update) updates.push(update)
}
Expand Down Expand Up @@ -74,11 +79,6 @@ namespace Stat {
return `'$."${key}"', IFNULL(JSON_EXTRACT(\`${name}\`, '$."${key}"'), 0) + ${value}`
}).join(', ')})`
}

add(field: K, key: string | number) {
const stat: Record<string, number> = this.data[field]
stat[key] = (stat[key] || 0) + 1
}
}

export class Numerical<K extends string> extends Stat<K, number> {
Expand Down

0 comments on commit 2a0bbfb

Please sign in to comment.