summaryrefslogtreecommitdiff
path: root/db.c
diff options
context:
space:
mode:
authorTrumeet <yuuta@yuuta.moe>2023-03-19 14:44:42 -0700
committerTrumeet <yuuta@yuuta.moe>2023-03-19 14:44:42 -0700
commit4389fe029f51e8ae24f3e68ad46a1064d822a8f6 (patch)
tree2a2164e362b246ff2adf5f3296855c41112cc4f3 /db.c
parent5633eccae8c8bc9387e63e22c0eb420eefa5e991 (diff)
downloadksyxbot-4389fe029f51e8ae24f3e68ad46a1064d822a8f6.tar
ksyxbot-4389fe029f51e8ae24f3e68ad46a1064d822a8f6.tar.gz
ksyxbot-4389fe029f51e8ae24f3e68ad46a1064d822a8f6.tar.bz2
ksyxbot-4389fe029f51e8ae24f3e68ad46a1064d822a8f6.zip
Use SQLite3 view to do global stats
Diffstat (limited to 'db.c')
-rw-r--r--db.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/db.c b/db.c
index 6c49f3d..98b35a0 100644
--- a/db.c
+++ b/db.c
@@ -20,7 +20,10 @@ static const char *sql_upgrades[] = {
"'user' INTEGER UNIQUE,"
"'i' INTEGER NOT NULL,"
"PRIMARY KEY('user')"
- ");"
+ ");",
+ "CREATE VIEW 'stat_global'"
+ "AS"
+ "SELECT * FROM (SELECT COUNT(user), SUM(i), MAX(i), AVG(i) FROM stats), (SELECT COUNT(msg) FROM says)"
};
sqlite3 *db = NULL;