@oh-my-pi/omp-stats 16.0.7 → 16.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/db.ts +11 -11
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/omp-stats",
|
|
4
|
-
"version": "16.0.
|
|
4
|
+
"version": "16.0.9",
|
|
5
5
|
"description": "Local observability dashboard for pi AI usage statistics",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"fmt": "biome format --write ."
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@oh-my-pi/pi-ai": "16.0.
|
|
41
|
-
"@oh-my-pi/pi-catalog": "16.0.
|
|
42
|
-
"@oh-my-pi/pi-utils": "16.0.
|
|
40
|
+
"@oh-my-pi/pi-ai": "16.0.9",
|
|
41
|
+
"@oh-my-pi/pi-catalog": "16.0.9",
|
|
42
|
+
"@oh-my-pi/pi-utils": "16.0.9",
|
|
43
43
|
"@tailwindcss/node": "^4.3.0",
|
|
44
44
|
"chart.js": "^4.5.1",
|
|
45
45
|
"date-fns": "^4.4.0",
|
package/src/db.ts
CHANGED
|
@@ -56,11 +56,11 @@ export async function initDb(): Promise<Database> {
|
|
|
56
56
|
db = new Database(getStatsDbPath());
|
|
57
57
|
// Install the busy handler BEFORE any lock-taking statement. See
|
|
58
58
|
// https://github.com/can1357/oh-my-pi/issues/2421.
|
|
59
|
-
db.
|
|
60
|
-
db.
|
|
59
|
+
db.run("PRAGMA busy_timeout = 5000");
|
|
60
|
+
db.run("PRAGMA journal_mode = WAL");
|
|
61
61
|
|
|
62
62
|
// Create tables
|
|
63
|
-
db.
|
|
63
|
+
db.run(`
|
|
64
64
|
CREATE TABLE IF NOT EXISTS messages (
|
|
65
65
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
66
66
|
session_file TEXT NOT NULL,
|
|
@@ -132,9 +132,9 @@ export async function initDb(): Promise<Database> {
|
|
|
132
132
|
|
|
133
133
|
const messageColumns = db.prepare("PRAGMA table_info(messages)").all() as { name: string }[];
|
|
134
134
|
if (!messageColumns.some(column => column.name === "premium_requests")) {
|
|
135
|
-
db.
|
|
135
|
+
db.run("ALTER TABLE messages ADD COLUMN premium_requests REAL NOT NULL DEFAULT 0");
|
|
136
136
|
}
|
|
137
|
-
db.
|
|
137
|
+
db.run("UPDATE messages SET premium_requests = 0 WHERE premium_requests IS NULL");
|
|
138
138
|
// Each behavior-metric bump invalidates previously-ingested rows. We detect
|
|
139
139
|
// the stale schema by column name and drop the table; `IF NOT EXISTS` above
|
|
140
140
|
// already produced the new schema, but we want a clean wipe + re-ingest.
|
|
@@ -159,8 +159,8 @@ export async function initDb(): Promise<Database> {
|
|
|
159
159
|
const hasV4Columns = userMessageColumns.some(column => column.name === "negation");
|
|
160
160
|
const hasOldUserMessages = userMessageColumns.length > 0;
|
|
161
161
|
if (hasStaleColumn || (hasOldUserMessages && !hasV4Columns)) {
|
|
162
|
-
db.
|
|
163
|
-
db.
|
|
162
|
+
db.run("DROP TABLE user_messages");
|
|
163
|
+
db.run(`
|
|
164
164
|
CREATE TABLE user_messages (
|
|
165
165
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
166
166
|
session_file TEXT NOT NULL,
|
|
@@ -787,8 +787,8 @@ function backfillUserMessages(database: Database): void {
|
|
|
787
787
|
| undefined;
|
|
788
788
|
if (!shouldResetBackfill(row?.value)) return;
|
|
789
789
|
|
|
790
|
-
database.
|
|
791
|
-
database.
|
|
790
|
+
database.run("DELETE FROM user_messages");
|
|
791
|
+
database.run("DELETE FROM file_offsets");
|
|
792
792
|
database
|
|
793
793
|
.prepare("INSERT OR REPLACE INTO meta (key, value) VALUES (?, ?)")
|
|
794
794
|
.run(USER_MESSAGES_BACKFILL_KEY, BACKFILL_PENDING);
|
|
@@ -808,7 +808,7 @@ function repairUserMessageLinks(database: Database): void {
|
|
|
808
808
|
| undefined;
|
|
809
809
|
if (!shouldResetBackfill(row?.value)) return;
|
|
810
810
|
|
|
811
|
-
database.
|
|
811
|
+
database.run("DELETE FROM file_offsets");
|
|
812
812
|
database
|
|
813
813
|
.prepare("INSERT OR REPLACE INTO meta (key, value) VALUES (?, ?)")
|
|
814
814
|
.run(USER_MESSAGE_LINKS_REPAIR_KEY, BACKFILL_PENDING);
|
|
@@ -830,7 +830,7 @@ function backfillPriorityPremiumRequests(database: Database): void {
|
|
|
830
830
|
| undefined;
|
|
831
831
|
if (!shouldResetBackfill(row?.value)) return;
|
|
832
832
|
|
|
833
|
-
database.
|
|
833
|
+
database.run("DELETE FROM file_offsets");
|
|
834
834
|
database
|
|
835
835
|
.prepare("INSERT OR REPLACE INTO meta (key, value) VALUES (?, ?)")
|
|
836
836
|
.run(PRIORITY_PREMIUM_REQUESTS_BACKFILL_KEY, BACKFILL_PENDING);
|