@atproto/ozone 0.4.2 → 0.5.0
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/CHANGELOG.md +38 -0
- package/dist/api/inbox/appealActionedSubject.d.ts +4 -0
- package/dist/api/inbox/appealActionedSubject.d.ts.map +1 -0
- package/dist/api/inbox/appealActionedSubject.js +60 -0
- package/dist/api/inbox/appealActionedSubject.js.map +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/label/subscribeLabels.d.ts.map +1 -1
- package/dist/api/label/subscribeLabels.js +4 -2
- package/dist/api/label/subscribeLabels.js.map +1 -1
- package/dist/api/queue/createQueue.d.ts.map +1 -1
- package/dist/api/queue/createQueue.js +22 -17
- package/dist/api/queue/createQueue.js.map +1 -1
- package/dist/api/queue/updateQueue.d.ts.map +1 -1
- package/dist/api/queue/updateQueue.js +33 -18
- package/dist/api/queue/updateQueue.js.map +1 -1
- package/dist/assignment/index.d.ts +1 -0
- package/dist/assignment/index.d.ts.map +1 -1
- package/dist/assignment/index.js +5 -0
- package/dist/assignment/index.js.map +1 -1
- package/dist/config/config.d.ts +11 -0
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +4 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/env.d.ts +1 -0
- package/dist/config/env.d.ts.map +1 -1
- package/dist/config/env.js +1 -0
- package/dist/config/env.js.map +1 -1
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/context.js.map +1 -1
- package/dist/daemon/stats-computer.d.ts +2 -8
- package/dist/daemon/stats-computer.d.ts.map +1 -1
- package/dist/daemon/stats-computer.js +21 -9
- package/dist/daemon/stats-computer.js.map +1 -1
- package/dist/db/migrations/20260219T164523000Z-create-report-table.js +2 -2
- package/dist/db/migrations/20260219T164523000Z-create-report-table.js.map +1 -1
- package/dist/db/migrations/20260810T000000000Z-add-report-stats-components.d.ts +4 -0
- package/dist/db/migrations/20260810T000000000Z-add-report-stats-components.d.ts.map +1 -0
- package/dist/db/migrations/20260810T000000000Z-add-report-stats-components.js +31 -0
- package/dist/db/migrations/20260810T000000000Z-add-report-stats-components.js.map +1 -0
- package/dist/db/migrations/20260922T153505234Z-add-report-closed-at-index.d.ts +4 -0
- package/dist/db/migrations/20260922T153505234Z-add-report-closed-at-index.d.ts.map +1 -0
- package/dist/db/migrations/20260922T153505234Z-add-report-closed-at-index.js +14 -0
- package/dist/db/migrations/20260922T153505234Z-add-report-closed-at-index.js.map +1 -0
- package/dist/db/migrations/20260928T000000000Z-inbox-appeal.d.ts +4 -0
- package/dist/db/migrations/20260928T000000000Z-inbox-appeal.d.ts.map +1 -0
- package/dist/db/migrations/20260928T000000000Z-inbox-appeal.js +25 -0
- package/dist/db/migrations/20260928T000000000Z-inbox-appeal.js.map +1 -0
- package/dist/db/migrations/index.d.ts +3 -0
- package/dist/db/migrations/index.d.ts.map +1 -1
- package/dist/db/migrations/index.js +3 -0
- package/dist/db/migrations/index.js.map +1 -1
- package/dist/db/schema/report.js.map +1 -1
- package/dist/db/schema/report_queue.d.ts +1 -0
- package/dist/db/schema/report_queue.d.ts.map +1 -1
- package/dist/db/schema/report_queue.js.map +1 -1
- package/dist/db/schema/report_stat.d.ts +11 -1
- package/dist/db/schema/report_stat.d.ts.map +1 -1
- package/dist/db/schema/report_stat.js.map +1 -1
- package/dist/inbox/appeal.d.ts +187 -0
- package/dist/inbox/appeal.d.ts.map +1 -0
- package/dist/inbox/appeal.js +340 -0
- package/dist/inbox/appeal.js.map +1 -0
- package/dist/inbox/views.d.ts +92 -0
- package/dist/inbox/views.d.ts.map +1 -0
- package/dist/inbox/views.js +313 -0
- package/dist/inbox/views.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lexicons/app/bsky/authFullApp.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/authFullApp.defs.js +10 -0
- package/dist/lexicons/app/bsky/authFullApp.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/feed/defs.defs.d.ts +8 -0
- package/dist/lexicons/app/bsky/feed/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/feed/defs.defs.js +2 -0
- package/dist/lexicons/app/bsky/feed/defs.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/feed/getQuotes.defs.d.ts +6 -0
- package/dist/lexicons/app/bsky/feed/getQuotes.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/feed/getQuotes.defs.js +2 -0
- package/dist/lexicons/app/bsky/feed/getQuotes.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.d.ts +3 -0
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.d.ts.map +1 -0
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.defs.d.ts +65 -0
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.defs.d.ts.map +1 -0
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.defs.js +49 -0
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.defs.js.map +1 -0
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.js +6 -0
- package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.js.map +1 -0
- package/dist/lexicons/tools/ozone/inbox/defs.d.ts +2 -0
- package/dist/lexicons/tools/ozone/inbox/defs.d.ts.map +1 -0
- package/dist/lexicons/tools/ozone/inbox/defs.defs.d.ts +89 -0
- package/dist/lexicons/tools/ozone/inbox/defs.defs.d.ts.map +1 -0
- package/dist/lexicons/tools/ozone/inbox/defs.defs.js +73 -0
- package/dist/lexicons/tools/ozone/inbox/defs.defs.js.map +1 -0
- package/dist/lexicons/tools/ozone/inbox/defs.js +5 -0
- package/dist/lexicons/tools/ozone/inbox/defs.js.map +1 -0
- package/dist/lexicons/tools/ozone/inbox.d.ts +3 -0
- package/dist/lexicons/tools/ozone/inbox.d.ts.map +1 -0
- package/dist/lexicons/tools/ozone/inbox.js +6 -0
- package/dist/lexicons/tools/ozone/inbox.js.map +1 -0
- package/dist/lexicons/tools/ozone/queue/createQueue.defs.d.ts +2 -0
- package/dist/lexicons/tools/ozone/queue/createQueue.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/queue/createQueue.defs.js +2 -0
- package/dist/lexicons/tools/ozone/queue/createQueue.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/queue/defs.defs.d.ts +4 -0
- package/dist/lexicons/tools/ozone/queue/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/queue/defs.defs.js +2 -0
- package/dist/lexicons/tools/ozone/queue/defs.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/queue/updateQueue.defs.d.ts +3 -1
- package/dist/lexicons/tools/ozone/queue/updateQueue.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/queue/updateQueue.defs.js +3 -0
- package/dist/lexicons/tools/ozone/queue/updateQueue.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/report/defs.defs.d.ts +89 -9
- package/dist/lexicons/tools/ozone/report/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/report/defs.defs.js +20 -0
- package/dist/lexicons/tools/ozone/report/defs.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/report/getLiveStats.defs.d.ts +1 -1
- package/dist/lexicons/tools/ozone/report/getLiveStats.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/report/getLiveStats.defs.js +1 -1
- package/dist/lexicons/tools/ozone/report/getLiveStats.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone/report/refreshStats.defs.d.ts +1 -1
- package/dist/lexicons/tools/ozone/report/refreshStats.defs.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone/report/refreshStats.defs.js +1 -1
- package/dist/lexicons/tools/ozone/report/refreshStats.defs.js.map +1 -1
- package/dist/lexicons/tools/ozone.d.ts +1 -0
- package/dist/lexicons/tools/ozone.d.ts.map +1 -1
- package/dist/lexicons/tools/ozone.js +1 -0
- package/dist/lexicons/tools/ozone.js.map +1 -1
- package/dist/mod-service/index.d.ts +6 -2
- package/dist/mod-service/index.d.ts.map +1 -1
- package/dist/mod-service/index.js +15 -6
- package/dist/mod-service/index.js.map +1 -1
- package/dist/queue/service.d.ts +16 -3
- package/dist/queue/service.d.ts.map +1 -1
- package/dist/queue/service.js +81 -27
- package/dist/queue/service.js.map +1 -1
- package/dist/report/stats.d.ts +25 -31
- package/dist/report/stats.d.ts.map +1 -1
- package/dist/report/stats.js +269 -175
- package/dist/report/stats.js.map +1 -1
- package/dist/report/views.d.ts.map +1 -1
- package/dist/report/views.js +20 -0
- package/dist/report/views.js.map +1 -1
- package/dist/sequencer/outbox.d.ts +3 -0
- package/dist/sequencer/outbox.d.ts.map +1 -1
- package/dist/sequencer/outbox.js +76 -42
- package/dist/sequencer/outbox.js.map +1 -1
- package/dist/video-invalidator.d.ts +9 -0
- package/dist/video-invalidator.d.ts.map +1 -0
- package/dist/video-invalidator.js +20 -0
- package/dist/video-invalidator.js.map +1 -0
- package/package.json +11 -13
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { sql } from 'kysely';
|
|
1
2
|
import { MINUTE } from '@atproto/common';
|
|
3
|
+
import { currentDatetimeString } from '@atproto/lex';
|
|
2
4
|
import { dbLogger } from '../logger.js';
|
|
3
5
|
import { STATS_COMPUTER_LOCK_ID } from './locks.js';
|
|
4
6
|
/**
|
|
@@ -8,14 +10,8 @@ import { STATS_COMPUTER_LOCK_ID } from './locks.js';
|
|
|
8
10
|
* and yesterday's snapshot is finalized if it wasn't already. Historical snapshots (completed
|
|
9
11
|
* days) are write-once and never recomputed unless explicitly refreshed via the API.
|
|
10
12
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* (+ 7 more for yesterday if finalization is needed).
|
|
14
|
-
* Day-window queries scan ~10K rows. Pending-count queries use partial indexes
|
|
15
|
-
* (WHERE status != 'closed') so only scan open reports, not the full table.
|
|
16
|
-
* Expected: ~10-50ms per query, ~100-350ms total report-table time.
|
|
17
|
-
* - ~40 lightweight reads against report_stat for freshness checks (small indexed table).
|
|
18
|
-
* - ~40 lightweight writes to report_stat for upserts.
|
|
13
|
+
* Each materialization batches inbound, pending, and lifecycle aggregation queries,
|
|
14
|
+
* then replaces the small set of daily aggregate, queue, reason, and moderator rows.
|
|
19
15
|
*
|
|
20
16
|
* Locking: Uses pg_try_advisory_lock to ensure only one instance materializes at a time
|
|
21
17
|
* when running multiple containers. Advisory locks are cooperative, session-level locks —
|
|
@@ -54,6 +50,7 @@ export class StatsComputer {
|
|
|
54
50
|
});
|
|
55
51
|
}
|
|
56
52
|
async materializeStats() {
|
|
53
|
+
const startedAt = Date.now();
|
|
57
54
|
let discardClient = false;
|
|
58
55
|
let locked = false;
|
|
59
56
|
const client = await this.db.pool.connect();
|
|
@@ -74,7 +71,22 @@ export class StatsComputer {
|
|
|
74
71
|
return;
|
|
75
72
|
}
|
|
76
73
|
const statsService = this.reportStatsServiceCreator(this.db);
|
|
77
|
-
await statsService.materializeAll();
|
|
74
|
+
const { rowsWritten } = await statsService.materializeAll();
|
|
75
|
+
const today = currentDatetimeString().slice(0, 10);
|
|
76
|
+
const latest = await this.db.db
|
|
77
|
+
.selectFrom('report_stat')
|
|
78
|
+
.select(sql `max("computedAt")`.as('computedAt'))
|
|
79
|
+
.where('date', '=', today)
|
|
80
|
+
.executeTakeFirst();
|
|
81
|
+
const stalenessMs = latest?.computedAt
|
|
82
|
+
? Math.max(0, Date.now() - new Date(latest.computedAt).getTime())
|
|
83
|
+
: null;
|
|
84
|
+
dbLogger.info({
|
|
85
|
+
event: 'stats_computer_cycle',
|
|
86
|
+
durationMs: Date.now() - startedAt,
|
|
87
|
+
rowsWritten,
|
|
88
|
+
stalenessMs,
|
|
89
|
+
}, 'stats computer cycle completed');
|
|
78
90
|
}
|
|
79
91
|
finally {
|
|
80
92
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stats-computer.js","sourceRoot":"","sources":["../../src/daemon/stats-computer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"stats-computer.js","sourceRoot":"","sources":["../../src/daemon/stats-computer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAGpD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,aAAa;IAKxB,YACU,EAAY,EACZ,yBAAoD;IAC5D;;;;OAIG;IACK,eAAuB;QAPvB,OAAE,GAAF,EAAE,CAAU;QACZ,8BAAyB,GAAzB,yBAAyB,CAA2B;QAMpD,oBAAe,GAAf,eAAe,CAAQ;QAZjC,cAAS,GAAG,KAAK,CAAA;QACjB,sBAAiB,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAA;IAYjD,CAAC;IAEJ,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,eAAe,GAAG,CAAC,CAAA;IACjC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,EAAE,CAAA;IACb,CAAC;IAED,IAAI;QACF,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAM;QAC3C,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,gBAAgB,EAAE;aAC7C,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,+BAA+B,CAAC,CAAC;aAC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AC,CAAA;gBACtB,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,OAAO,EAAE,CAAA;gBAClB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;QACrB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACxB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;QACxB,CAAC;QACD,MAAM,IAAI,CAAC,iBAAiB,CAAA;IAC9B,CAAC;CACF","sourcesContent":["import { sql } from 'kysely'\nimport { MINUTE } from '@atproto/common'\nimport { currentDatetimeString } from '@atproto/lex'\nimport type { Database } from '../db/index.js'\nimport type { DateString } from '../db/schema/report_stat.js'\nimport { dbLogger } from '../logger.js'\nimport type { ReportStatsServiceCreator } from '../report/stats.js'\nimport { STATS_COMPUTER_LOCK_ID } from './locks.js'\n\n/**\n * Background daemon that materializes report statistics on an interval (default is 15 minutes).\n *\n * Each cycle computes calendar-day snapshots: today's stats are recomputed (in-progress day),\n * and yesterday's snapshot is finalized if it wasn't already. Historical snapshots (completed\n * days) are write-once and never recomputed unless explicitly refreshed via the API.\n *\n * Each materialization batches inbound, pending, and lifecycle aggregation queries,\n * then replaces the small set of daily aggregate, queue, reason, and moderator rows.\n *\n * Locking: Uses pg_try_advisory_lock to ensure only one instance materializes at a time\n * when running multiple containers. Advisory locks are cooperative, session-level locks —\n * they do NOT block any table reads, writes, row locks, or transactions from other sessions.\n * Normal application queries (report creation, moderation actions, API reads) are completely\n * unaffected. If another instance already holds the lock, this instance skips the cycle\n * immediately without blocking.\n */\nexport class StatsComputer {\n destroyed = false\n processingPromise: Promise<void> = Promise.resolve()\n timer?: NodeJS.Timeout\n\n constructor(\n private db: Database,\n private reportStatsServiceCreator: ReportStatsServiceCreator,\n /**\n * Minutes between stats computer cycles.\n * Defaults to 15. Minimum is 1.\n * Set to -1 to disable the stats computer.\n */\n private intervalMinutes: number,\n ) {}\n\n get disabled() {\n return this.intervalMinutes < 1\n }\n\n start() {\n this.poll()\n }\n\n poll() {\n if (this.destroyed || this.disabled) return\n this.processingPromise = this.materializeStats()\n .catch((err) => dbLogger.error({ err }, 'stats materialization errored'))\n .finally(() => {\n this.timer = setTimeout(\n () => this.poll(),\n this.intervalMinutes * MINUTE,\n )\n })\n }\n\n private async materializeStats() {\n const startedAt = Date.now()\n let discardClient = false\n let locked = false\n const client = await this.db.pool.connect()\n const lockScope = this.db.schema ?? 'public'\n\n try {\n const lockResult = await client\n .query<{ locked: boolean }>(\n `SELECT pg_try_advisory_lock(\n hashtextextended(current_database() || ':' || $2::text, $1)\n ) as locked`,\n [STATS_COMPUTER_LOCK_ID, lockScope],\n )\n .catch((err) => {\n // The server may have acquired the lock before the query failed.\n discardClient = true\n throw err\n })\n locked = lockResult.rows[0]?.locked === true\n if (!locked) {\n dbLogger.info(\n 'stats materialization skipped, another instance holds lock',\n )\n return\n }\n\n const statsService = this.reportStatsServiceCreator(this.db)\n const { rowsWritten } = await statsService.materializeAll()\n const today = currentDatetimeString().slice(0, 10) as DateString\n const latest = await this.db.db\n .selectFrom('report_stat')\n .select(sql<string | null>`max(\"computedAt\")`.as('computedAt'))\n .where('date', '=', today)\n .executeTakeFirst()\n const stalenessMs = latest?.computedAt\n ? Math.max(0, Date.now() - new Date(latest.computedAt).getTime())\n : null\n dbLogger.info(\n {\n event: 'stats_computer_cycle',\n durationMs: Date.now() - startedAt,\n rowsWritten,\n stalenessMs,\n },\n 'stats computer cycle completed',\n )\n } finally {\n try {\n if (locked) {\n const unlockResult = await client.query<{ unlocked: boolean }>(\n `SELECT pg_advisory_unlock(\n hashtextextended(current_database() || ':' || $2::text, $1)\n ) as unlocked`,\n [STATS_COMPUTER_LOCK_ID, lockScope],\n )\n if (unlockResult.rows[0]?.unlocked !== true) {\n dbLogger.warn('stats materialization lock was not held at release')\n }\n }\n } catch (err) {\n discardClient = true\n dbLogger.warn({ err }, 'failed to release stats materialization lock')\n } finally {\n if (discardClient) {\n // Destroy an uncertain session so it cannot leak the lock.\n client.release(true)\n } else {\n client.release()\n }\n }\n }\n }\n\n async destroy() {\n this.destroyed = true\n if (this.timer) {\n clearTimeout(this.timer)\n this.timer = undefined\n }\n await this.processingPromise\n }\n}\n"]}
|
|
@@ -10,8 +10,8 @@ export async function up(db) {
|
|
|
10
10
|
// Queue assignment (computed by background job in future iteration)
|
|
11
11
|
.addColumn('queueId', 'integer') // NULL = not yet assigned, -1 = no matching queue
|
|
12
12
|
.addColumn('queuedAt', 'varchar')
|
|
13
|
-
// Action linkage
|
|
14
|
-
.addColumn('actionEventIds', 'jsonb') //
|
|
13
|
+
// Action linkage
|
|
14
|
+
.addColumn('actionEventIds', 'jsonb') // Event IDs in append order (most recently linked last)
|
|
15
15
|
// Reporter communication
|
|
16
16
|
.addColumn('actionNote', 'text')
|
|
17
17
|
// Whether the report is muted (reporter was muted or subject was muted at creation time)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20260219T164523000Z-create-report-table.js","sourceRoot":"","sources":["../../../src/db/migrations/20260219T164523000Z-create-report-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,GAAG,EAAE,MAAM,QAAQ,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAE/C,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,EAAmB;IAC1C,wDAAwD;IACxD,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,QAAQ,CAAC;SACrB,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;QAErD,sFAAsF;SACrF,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC;QAEjE,oEAAoE;SACn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port { tools } from '../../lexicons/index.js'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n // Report table - bridges report events to action events\n await db.schema\n .createTable('report')\n .addColumn('id', 'serial', (col) => col.primaryKey())\n\n // Core link to report event (display data still comes from moderation_event via JOIN)\n .addColumn('eventId', 'integer', (col) => col.notNull().unique())\n\n // Queue assignment (computed by background job in future iteration)\n .addColumn('queueId', 'integer') // NULL = not yet assigned, -1 = no matching queue\n .addColumn('queuedAt', 'varchar')\n\n // Action linkage (sorted DESC, most recent first)\n .addColumn('actionEventIds', 'jsonb') // Array of event IDs: [newest_id, ..., oldest_id]\n\n // Reporter communication\n .addColumn('actionNote', 'text')\n\n // Whether the report is muted (reporter was muted or subject was muted at creation time)\n .addColumn('isMuted', 'boolean', (col) => col.notNull().defaultTo(false))\n\n // Status of the ticket/report\n .addColumn('status', 'varchar', (col) => col.notNull().defaultTo('open')) // \"open\", \"closed\", \"escalated\"\n\n // Denormalized from moderation_event for filtering without JOIN\n .addColumn('reportType', 'varchar', (col) => col.notNull())\n .addColumn('did', 'varchar', (col) => col.notNull())\n .addColumn('recordPath', 'varchar', (col) => col.notNull().defaultTo('')) // '' = account/message, 'collection/rkey' = record\n .addColumn('subjectMessageId', 'varchar') // NULL for non-message subjects\n\n // Timestamps\n .addColumn('createdAt', 'varchar', (col) => col.notNull())\n .addColumn('updatedAt', 'varchar', (col) => col.notNull())\n .addColumn('assignedTo', 'varchar') // DID of permanently assigned moderator\n .addColumn('assignedAt', 'varchar') // When the permanent assignment was created\n .addColumn('closedAt', 'varchar')\n .execute()\n\n // ─── Indexes ───\n // Primary JOIN index - critical for every query that fetches display data from moderation_event\n await db.schema\n .createIndex('idx_report_event')\n .on('report')\n .column('eventId')\n .execute()\n\n // ─── Hot path: active reports (status != 'closed') ───\n // Partial filter keeps these tight even as closed reports accumulate (~90% of table long-term).\n // No isMuted in key (low cardinality, rarely filtered) and no INCLUDE columns\n // (display data comes from moderation_event JOIN anyway).\n\n // queryReports: queueId + status, paginated by createdAt\n await sql`CREATE INDEX idx_report_active_queue_created ON report\n (\"queueId\", status, \"createdAt\" DESC, id DESC)\n WHERE status != 'closed'`.execute(db)\n\n // queryReports: queueId + status, paginated by updatedAt\n await sql`CREATE INDEX idx_report_active_queue_updated ON report\n (\"queueId\", status, \"updatedAt\" DESC, id DESC)\n WHERE status != 'closed'`.execute(db)\n\n // queryReports: status only, paginated by createdAt\n await sql`CREATE INDEX idx_report_active_status_created ON report\n (status, \"createdAt\" DESC, id DESC)\n WHERE status != 'closed'`.execute(db)\n\n // queryReports: status only, paginated by updatedAt\n await sql`CREATE INDEX idx_report_active_status_updated ON report\n (status, \"updatedAt\" DESC, id DESC)\n WHERE status != 'closed'`.execute(db)\n\n // Active reports for a specific account (with optional queueId post-filter)\n await sql`CREATE INDEX idx_report_active_did_created ON report\n (did, status, \"createdAt\" DESC, id DESC)\n WHERE status != 'closed'`.execute(db)\n\n // A moderator's active workload (with optional queueId post-filter)\n await sql`CREATE INDEX idx_report_active_assigned_created ON report\n (\"assignedTo\", status, \"createdAt\" DESC, id DESC)\n WHERE status != 'closed'`.execute(db)\n\n // findReportsForSubject hot path — always filters NOT IN ('closed').\n // did + recordPath identify the subject (account or specific record).\n await sql`CREATE INDEX idx_report_subject_active ON report\n (did, \"recordPath\", \"createdAt\" DESC, id DESC)\n WHERE status != 'closed'`.execute(db)\n\n // ─── Closed history (status = 'closed') ───\n // Closed reports are terminal; only sort by createdAt.\n\n // Closed pagination per queue\n await sql`CREATE INDEX idx_report_closed_queue_created ON report\n (\"queueId\", \"createdAt\" DESC, id DESC)\n WHERE status = 'closed'`.execute(db)\n\n // Closed history for an account\n await sql`CREATE INDEX idx_report_closed_did_created ON report\n (did, \"createdAt\" DESC, id DESC)\n WHERE status = 'closed'`.execute(db)\n\n // Moderator's closed-report history\n await sql`CREATE INDEX idx_report_closed_assigned_created ON report\n (\"assignedTo\", \"createdAt\" DESC, id DESC)\n WHERE status = 'closed'`.execute(db)\n\n // ─── Other access patterns ───\n\n // Collection prefix queries: left-anchored LIKE 'app.bsky.feed.post/%' or 'app.bsky.%'\n // text_pattern_ops enables btree-scannable prefix matching (supported since Postgres 8.x)\n await sql`CREATE INDEX idx_report_record_path_pattern ON report\n (\"recordPath\" text_pattern_ops)`.execute(db)\n\n // Queue-router covering partial: index-only scan over unrouted, non-closed rows.\n // Selects exactly the columns the router reads, eliminating heap fetches per batch.\n await sql`CREATE INDEX idx_report_unassigned_id ON report (id)\n INCLUDE (status, \"reportType\", \"recordPath\", \"subjectMessageId\")\n WHERE \"queueId\" IS NULL AND status != 'closed'`.execute(db)\n\n // Index for report statistics\n await db.schema\n .createIndex('idx_report_queue_created_id')\n .on('report')\n .columns(['queueId', 'createdAt', 'id'])\n .execute()\n\n // aggregate pending count query\n await sql`CREATE INDEX idx_report_pending ON report (id) WHERE status != 'closed'`.execute(\n db,\n )\n // per-queue pending count query\n await sql`CREATE INDEX idx_report_queue_pending ON report (\"queueId\") WHERE status != 'closed'`.execute(\n db,\n )\n\n // Queue-router event-source partial: scans new modEventReport rows by id\n // for the daemon that inserts report rows from moderation_event.\n await sql`CREATE INDEX moderation_event_report_id_idx\n ON moderation_event (id)\n WHERE action = ${sql.lit(tools.ozone.moderation.defs.modEventReport.$type)}`.execute(\n db,\n )\n\n // Stats windowed queries: aggregate/typeWindow filter by createdAt range and\n // include both open and closed reports, so they cannot use the partial indexes\n // above. (createdAt, reportType) ordering serves the date-range scan and\n // satisfies GROUP BY reportType from the index without a heap fetch.\n await sql`CREATE INDEX idx_report_created_type\n ON report (\"createdAt\", \"reportType\")`.execute(db)\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema.dropIndex('moderation_event_report_id_idx').execute()\n await db.schema.dropTable('report').execute()\n}\n"]}
|
|
1
|
+
{"version":3,"file":"20260219T164523000Z-create-report-table.js","sourceRoot":"","sources":["../../../src/db/migrations/20260219T164523000Z-create-report-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,GAAG,EAAE,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CAAC,EAAE,CAAC,OAAO,CACpF,EAAE,CACH,CAAA;IAED,6EAA6E;IAC7E,+EAA+E;IAC/E,yEAAyE;IACzE,qEAAqE;IACrE,MAAM,GAAG,CAAA;0CAC+B,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;AACtD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,gCAAgC,CAAC,CAAC,OAAO,EAAE,CAAA;IACrE,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAA;AAC/C,CAAC","sourcesContent":["import { type Kysely, sql } from 'kysely'\nimport { tools } from '../../lexicons/index.js'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n // Report table - bridges report events to action events\n await db.schema\n .createTable('report')\n .addColumn('id', 'serial', (col) => col.primaryKey())\n\n // Core link to report event (display data still comes from moderation_event via JOIN)\n .addColumn('eventId', 'integer', (col) => col.notNull().unique())\n\n // Queue assignment (computed by background job in future iteration)\n .addColumn('queueId', 'integer') // NULL = not yet assigned, -1 = no matching queue\n .addColumn('queuedAt', 'varchar')\n\n // Action linkage\n .addColumn('actionEventIds', 'jsonb') // Event IDs in append order (most recently linked last)\n\n // Reporter communication\n .addColumn('actionNote', 'text')\n\n // Whether the report is muted (reporter was muted or subject was muted at creation time)\n .addColumn('isMuted', 'boolean', (col) => col.notNull().defaultTo(false))\n\n // Status of the ticket/report\n .addColumn('status', 'varchar', (col) => col.notNull().defaultTo('open')) // \"open\", \"closed\", \"escalated\"\n\n // Denormalized from moderation_event for filtering without JOIN\n .addColumn('reportType', 'varchar', (col) => col.notNull())\n .addColumn('did', 'varchar', (col) => col.notNull())\n .addColumn('recordPath', 'varchar', (col) => col.notNull().defaultTo('')) // '' = account/message, 'collection/rkey' = record\n .addColumn('subjectMessageId', 'varchar') // NULL for non-message subjects\n\n // Timestamps\n .addColumn('createdAt', 'varchar', (col) => col.notNull())\n .addColumn('updatedAt', 'varchar', (col) => col.notNull())\n .addColumn('assignedTo', 'varchar') // DID of permanently assigned moderator\n .addColumn('assignedAt', 'varchar') // When the permanent assignment was created\n .addColumn('closedAt', 'varchar')\n .execute()\n\n // ─── Indexes ───\n // Primary JOIN index - critical for every query that fetches display data from moderation_event\n await db.schema\n .createIndex('idx_report_event')\n .on('report')\n .column('eventId')\n .execute()\n\n // ─── Hot path: active reports (status != 'closed') ───\n // Partial filter keeps these tight even as closed reports accumulate (~90% of table long-term).\n // No isMuted in key (low cardinality, rarely filtered) and no INCLUDE columns\n // (display data comes from moderation_event JOIN anyway).\n\n // queryReports: queueId + status, paginated by createdAt\n await sql`CREATE INDEX idx_report_active_queue_created ON report\n (\"queueId\", status, \"createdAt\" DESC, id DESC)\n WHERE status != 'closed'`.execute(db)\n\n // queryReports: queueId + status, paginated by updatedAt\n await sql`CREATE INDEX idx_report_active_queue_updated ON report\n (\"queueId\", status, \"updatedAt\" DESC, id DESC)\n WHERE status != 'closed'`.execute(db)\n\n // queryReports: status only, paginated by createdAt\n await sql`CREATE INDEX idx_report_active_status_created ON report\n (status, \"createdAt\" DESC, id DESC)\n WHERE status != 'closed'`.execute(db)\n\n // queryReports: status only, paginated by updatedAt\n await sql`CREATE INDEX idx_report_active_status_updated ON report\n (status, \"updatedAt\" DESC, id DESC)\n WHERE status != 'closed'`.execute(db)\n\n // Active reports for a specific account (with optional queueId post-filter)\n await sql`CREATE INDEX idx_report_active_did_created ON report\n (did, status, \"createdAt\" DESC, id DESC)\n WHERE status != 'closed'`.execute(db)\n\n // A moderator's active workload (with optional queueId post-filter)\n await sql`CREATE INDEX idx_report_active_assigned_created ON report\n (\"assignedTo\", status, \"createdAt\" DESC, id DESC)\n WHERE status != 'closed'`.execute(db)\n\n // findReportsForSubject hot path — always filters NOT IN ('closed').\n // did + recordPath identify the subject (account or specific record).\n await sql`CREATE INDEX idx_report_subject_active ON report\n (did, \"recordPath\", \"createdAt\" DESC, id DESC)\n WHERE status != 'closed'`.execute(db)\n\n // ─── Closed history (status = 'closed') ───\n // Closed reports are terminal; only sort by createdAt.\n\n // Closed pagination per queue\n await sql`CREATE INDEX idx_report_closed_queue_created ON report\n (\"queueId\", \"createdAt\" DESC, id DESC)\n WHERE status = 'closed'`.execute(db)\n\n // Closed history for an account\n await sql`CREATE INDEX idx_report_closed_did_created ON report\n (did, \"createdAt\" DESC, id DESC)\n WHERE status = 'closed'`.execute(db)\n\n // Moderator's closed-report history\n await sql`CREATE INDEX idx_report_closed_assigned_created ON report\n (\"assignedTo\", \"createdAt\" DESC, id DESC)\n WHERE status = 'closed'`.execute(db)\n\n // ─── Other access patterns ───\n\n // Collection prefix queries: left-anchored LIKE 'app.bsky.feed.post/%' or 'app.bsky.%'\n // text_pattern_ops enables btree-scannable prefix matching (supported since Postgres 8.x)\n await sql`CREATE INDEX idx_report_record_path_pattern ON report\n (\"recordPath\" text_pattern_ops)`.execute(db)\n\n // Queue-router covering partial: index-only scan over unrouted, non-closed rows.\n // Selects exactly the columns the router reads, eliminating heap fetches per batch.\n await sql`CREATE INDEX idx_report_unassigned_id ON report (id)\n INCLUDE (status, \"reportType\", \"recordPath\", \"subjectMessageId\")\n WHERE \"queueId\" IS NULL AND status != 'closed'`.execute(db)\n\n // Index for report statistics\n await db.schema\n .createIndex('idx_report_queue_created_id')\n .on('report')\n .columns(['queueId', 'createdAt', 'id'])\n .execute()\n\n // aggregate pending count query\n await sql`CREATE INDEX idx_report_pending ON report (id) WHERE status != 'closed'`.execute(\n db,\n )\n // per-queue pending count query\n await sql`CREATE INDEX idx_report_queue_pending ON report (\"queueId\") WHERE status != 'closed'`.execute(\n db,\n )\n\n // Queue-router event-source partial: scans new modEventReport rows by id\n // for the daemon that inserts report rows from moderation_event.\n await sql`CREATE INDEX moderation_event_report_id_idx\n ON moderation_event (id)\n WHERE action = ${sql.lit(tools.ozone.moderation.defs.modEventReport.$type)}`.execute(\n db,\n )\n\n // Stats windowed queries: aggregate/typeWindow filter by createdAt range and\n // include both open and closed reports, so they cannot use the partial indexes\n // above. (createdAt, reportType) ordering serves the date-range scan and\n // satisfies GROUP BY reportType from the index without a heap fetch.\n await sql`CREATE INDEX idx_report_created_type\n ON report (\"createdAt\", \"reportType\")`.execute(db)\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema.dropIndex('moderation_event_report_id_idx').execute()\n await db.schema.dropTable('report').execute()\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20260810T000000000Z-add-report-stats-components.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20260810T000000000Z-add-report-stats-components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC,wBAAsB,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAc3D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAc7D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export async function up(db) {
|
|
2
|
+
await db.schema
|
|
3
|
+
.alterTable('report_stat')
|
|
4
|
+
.addColumn('closedCount', 'integer')
|
|
5
|
+
.addColumn('acknowledgedCount', 'integer')
|
|
6
|
+
.addColumn('labelActionCount', 'integer')
|
|
7
|
+
.addColumn('tagActionCount', 'integer')
|
|
8
|
+
.addColumn('takedownActionCount', 'integer')
|
|
9
|
+
.addColumn('ahtDurationSec', 'bigint')
|
|
10
|
+
.addColumn('ahtSampleCount', 'integer')
|
|
11
|
+
.addColumn('resolutionDurationSec', 'bigint')
|
|
12
|
+
.addColumn('resolutionSampleCount', 'integer')
|
|
13
|
+
.addColumn('avgResolutionTimeSec', 'integer')
|
|
14
|
+
.execute();
|
|
15
|
+
}
|
|
16
|
+
export async function down(db) {
|
|
17
|
+
await db.schema
|
|
18
|
+
.alterTable('report_stat')
|
|
19
|
+
.dropColumn('closedCount')
|
|
20
|
+
.dropColumn('acknowledgedCount')
|
|
21
|
+
.dropColumn('labelActionCount')
|
|
22
|
+
.dropColumn('tagActionCount')
|
|
23
|
+
.dropColumn('takedownActionCount')
|
|
24
|
+
.dropColumn('ahtDurationSec')
|
|
25
|
+
.dropColumn('ahtSampleCount')
|
|
26
|
+
.dropColumn('resolutionDurationSec')
|
|
27
|
+
.dropColumn('resolutionSampleCount')
|
|
28
|
+
.dropColumn('avgResolutionTimeSec')
|
|
29
|
+
.execute();
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=20260810T000000000Z-add-report-stats-components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20260810T000000000Z-add-report-stats-components.js","sourceRoot":"","sources":["../../../src/db/migrations/20260810T000000000Z-add-report-stats-components.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,EAAmB;IAC1C,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,aAAa,CAAC;SACzB,SAAS,CAAC,aAAa,EAAE,SAAS,CAAC;SACnC,SAAS,CAAC,mBAAmB,EAAE,SAAS,CAAC;SACzC,SAAS,CAAC,kBAAkB,EAAE,SAAS,CAAC;SACxC,SAAS,CAAC,gBAAgB,EAAE,SAAS,CAAC;SACtC,SAAS,CAAC,qBAAqB,EAAE,SAAS,CAAC;SAC3C,SAAS,CAAC,gBAAgB,EAAE,QAAQ,CAAC;SACrC,SAAS,CAAC,gBAAgB,EAAE,SAAS,CAAC;SACtC,SAAS,CAAC,uBAAuB,EAAE,QAAQ,CAAC;SAC5C,SAAS,CAAC,uBAAuB,EAAE,SAAS,CAAC;SAC7C,SAAS,CAAC,sBAAsB,EAAE,SAAS,CAAC;SAC5C,OAAO,EAAE,CAAA;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,aAAa,CAAC;SACzB,UAAU,CAAC,aAAa,CAAC;SACzB,UAAU,CAAC,mBAAmB,CAAC;SAC/B,UAAU,CAAC,kBAAkB,CAAC;SAC9B,UAAU,CAAC,gBAAgB,CAAC;SAC5B,UAAU,CAAC,qBAAqB,CAAC;SACjC,UAAU,CAAC,gBAAgB,CAAC;SAC5B,UAAU,CAAC,gBAAgB,CAAC;SAC5B,UAAU,CAAC,uBAAuB,CAAC;SACnC,UAAU,CAAC,uBAAuB,CAAC;SACnC,UAAU,CAAC,sBAAsB,CAAC;SAClC,OAAO,EAAE,CAAA;AACd,CAAC","sourcesContent":["import type { Kysely } from 'kysely'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .alterTable('report_stat')\n .addColumn('closedCount', 'integer')\n .addColumn('acknowledgedCount', 'integer')\n .addColumn('labelActionCount', 'integer')\n .addColumn('tagActionCount', 'integer')\n .addColumn('takedownActionCount', 'integer')\n .addColumn('ahtDurationSec', 'bigint')\n .addColumn('ahtSampleCount', 'integer')\n .addColumn('resolutionDurationSec', 'bigint')\n .addColumn('resolutionSampleCount', 'integer')\n .addColumn('avgResolutionTimeSec', 'integer')\n .execute()\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .alterTable('report_stat')\n .dropColumn('closedCount')\n .dropColumn('acknowledgedCount')\n .dropColumn('labelActionCount')\n .dropColumn('tagActionCount')\n .dropColumn('takedownActionCount')\n .dropColumn('ahtDurationSec')\n .dropColumn('ahtSampleCount')\n .dropColumn('resolutionDurationSec')\n .dropColumn('resolutionSampleCount')\n .dropColumn('avgResolutionTimeSec')\n .execute()\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20260922T153505234Z-add-report-closed-at-index.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20260922T153505234Z-add-report-closed-at-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC,wBAAsB,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAS3D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export async function up(db) {
|
|
2
|
+
// @NOTE Daily closure statistics filter by closedAt rather than createdAt.
|
|
3
|
+
// Index only closed reports so date-range queries can avoid scanning report history.
|
|
4
|
+
await db.schema
|
|
5
|
+
.createIndex('idx_report_closed_at')
|
|
6
|
+
.on('report')
|
|
7
|
+
.column('closedAt')
|
|
8
|
+
.where('closedAt', 'is not', null)
|
|
9
|
+
.execute();
|
|
10
|
+
}
|
|
11
|
+
export async function down(db) {
|
|
12
|
+
await db.schema.dropIndex('idx_report_closed_at').execute();
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=20260922T153505234Z-add-report-closed-at-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20260922T153505234Z-add-report-closed-at-index.js","sourceRoot":"","sources":["../../../src/db/migrations/20260922T153505234Z-add-report-closed-at-index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,EAAmB;IAC1C,2EAA2E;IAC3E,qFAAqF;IACrF,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,sBAAsB,CAAC;SACnC,EAAE,CAAC,QAAQ,CAAC;SACZ,MAAM,CAAC,UAAU,CAAC;SAClB,KAAK,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC;SACjC,OAAO,EAAE,CAAA;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC,OAAO,EAAE,CAAA;AAC7D,CAAC","sourcesContent":["import type { Kysely } from 'kysely'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n // @NOTE Daily closure statistics filter by closedAt rather than createdAt.\n // Index only closed reports so date-range queries can avoid scanning report history.\n await db.schema\n .createIndex('idx_report_closed_at')\n .on('report')\n .column('closedAt')\n .where('closedAt', 'is not', null)\n .execute()\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema.dropIndex('idx_report_closed_at').execute()\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20260928T000000000Z-inbox-appeal.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20260928T000000000Z-inbox-appeal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAO,MAAM,QAAQ,CAAA;AAEzC,wBAAsB,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB3D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAM7D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { sql } from 'kysely';
|
|
2
|
+
export async function up(db) {
|
|
3
|
+
await db.schema
|
|
4
|
+
.alterTable('report_queue')
|
|
5
|
+
.addColumn('recommendedLabels', 'jsonb', (col) => col.notNull().defaultTo(sql `'[]'::jsonb`))
|
|
6
|
+
.execute();
|
|
7
|
+
// @NOTE: This index should be created CONCURRENTLY in production. Kysely's
|
|
8
|
+
// migration transaction does not support that option.
|
|
9
|
+
// Appeal lookups span open and closed reports - a record gets one appeal
|
|
10
|
+
// ever, so a closed one still blocks - which the existing partial indexes on
|
|
11
|
+
// report deliberately do not cover.
|
|
12
|
+
await sql `
|
|
13
|
+
CREATE INDEX IF NOT EXISTS idx_report_appeal_subject
|
|
14
|
+
ON report (did, "recordPath", id DESC)
|
|
15
|
+
WHERE "reportType" = 'tools.ozone.report.defs#reasonAppeal'
|
|
16
|
+
`.execute(db);
|
|
17
|
+
}
|
|
18
|
+
export async function down(db) {
|
|
19
|
+
await db.schema.dropIndex('idx_report_appeal_subject').ifExists().execute();
|
|
20
|
+
await db.schema
|
|
21
|
+
.alterTable('report_queue')
|
|
22
|
+
.dropColumn('recommendedLabels')
|
|
23
|
+
.execute();
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=20260928T000000000Z-inbox-appeal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20260928T000000000Z-inbox-appeal.js","sourceRoot":"","sources":["../../../src/db/migrations/20260928T000000000Z-inbox-appeal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,GAAG,EAAE,MAAM,QAAQ,CAAA;AAEzC,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,EAAmB;IAC1C,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,cAAc,CAAC;SAC1B,SAAS,CAAC,mBAAmB,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAC/C,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,GAAG,CAAA,aAAa,CAAC,CAC1C;SACA,OAAO,EAAE,CAAA;IAEZ,2EAA2E;IAC3E,sDAAsD;IACtD,yEAAyE;IACzE,6EAA6E;IAC7E,oCAAoC;IACpC,MAAM,GAAG,CAAA;;;;GAIR,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAA;IAC3E,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,cAAc,CAAC;SAC1B,UAAU,CAAC,mBAAmB,CAAC;SAC/B,OAAO,EAAE,CAAA;AACd,CAAC","sourcesContent":["import { type Kysely, sql } from 'kysely'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .alterTable('report_queue')\n .addColumn('recommendedLabels', 'jsonb', (col) =>\n col.notNull().defaultTo(sql`'[]'::jsonb`),\n )\n .execute()\n\n // @NOTE: This index should be created CONCURRENTLY in production. Kysely's\n // migration transaction does not support that option.\n // Appeal lookups span open and closed reports - a record gets one appeal\n // ever, so a closed one still blocks - which the existing partial indexes on\n // report deliberately do not cover.\n await sql`\n CREATE INDEX IF NOT EXISTS idx_report_appeal_subject\n ON report (did, \"recordPath\", id DESC)\n WHERE \"reportType\" = 'tools.ozone.report.defs#reasonAppeal'\n `.execute(db)\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema.dropIndex('idx_report_appeal_subject').ifExists().execute()\n await db.schema\n .alterTable('report_queue')\n .dropColumn('recommendedLabels')\n .execute()\n}\n"]}
|
|
@@ -41,4 +41,7 @@ export * as _20260602T120000000Z from './20260602T120000000Z-add-report-activity
|
|
|
41
41
|
export * as _20260617T210022765Z from './20260617T210022765Z-add-report-isautomated.js';
|
|
42
42
|
export * as _20260720T000000000Z from './20260720T000000000Z-add-convo-subjects-to-stats-views.js';
|
|
43
43
|
export * as _20260731T000000000Z from './20260731T000000000Z-add-recommended-policies-to-report-queue.js';
|
|
44
|
+
export * as _20260810T000000000Z from './20260810T000000000Z-add-report-stats-components.js';
|
|
45
|
+
export * as _20260922T153505234Z from './20260922T153505234Z-add-report-closed-at-index.js';
|
|
46
|
+
export * as _20260928T000000000Z from './20260928T000000000Z-inbox-appeal.js';
|
|
44
47
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,oBAAoB,MAAM,+BAA+B,CAAA;AACrE,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;A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MAAM,oDAAoD,CAAA;AAC1F,OAAO,KAAK,oBAAoB,MAAM,0CAA0C,CAAA;AAChF,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,+CAA+C,CAAA;AACrF,OAAO,KAAK,oBAAoB,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK,oBAAoB,MAAM,mEAAmE,CAAA;AACzG,OAAO,KAAK,oBAAoB,MAAM,sDAAsD,CAAA;AAC5F,OAAO,KAAK,oBAAoB,MAAM,qDAAqD,CAAA;AAC3F,OAAO,KAAK,oBAAoB,MAAM,uCAAuC,CAAA"}
|
|
@@ -44,4 +44,7 @@ export * as _20260602T120000000Z from './20260602T120000000Z-add-report-activity
|
|
|
44
44
|
export * as _20260617T210022765Z from './20260617T210022765Z-add-report-isautomated.js';
|
|
45
45
|
export * as _20260720T000000000Z from './20260720T000000000Z-add-convo-subjects-to-stats-views.js';
|
|
46
46
|
export * as _20260731T000000000Z from './20260731T000000000Z-add-recommended-policies-to-report-queue.js';
|
|
47
|
+
export * as _20260810T000000000Z from './20260810T000000000Z-add-report-stats-components.js';
|
|
48
|
+
export * as _20260922T153505234Z from './20260922T153505234Z-add-report-closed-at-index.js';
|
|
49
|
+
export * as _20260928T000000000Z from './20260928T000000000Z-inbox-appeal.js';
|
|
47
50
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db/migrations/index.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,gGAAgG;AAChG,+FAA+F;AAE/F,OAAO,KAAK,oBAAoB,MAAM,+BAA+B,CAAA;AACrE,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,0CAA0C,CA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AACxF,OAAO,KAAK,oBAAoB,MAAM,4CAA4C,CAAA;AAClF,OAAO,KAAK,oBAAoB,MAAM,4CAA4C,CAAA;AAClF,OAAO,KAAK,oBAAoB,MAAM,uDAAuD,CAAA;AAC7F,OAAO,KAAK,oBAAoB,MAAM,8CAA8C,CAAA;AACpF,OAAO,KAAK,oBAAoB,MAAM,+CAA+C,CAAA;AACrF,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,oDAAoD,CAAA;AAC1F,OAAO,KAAK,oBAAoB,MAAM,0CAA0C,CAAA;AAChF,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,+CAA+C,CAAA;AACrF,OAAO,KAAK,oBAAoB,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK,oBAAoB,MAAM,mEAAmE,CAAA","sourcesContent":["// NOTE this file can be edited by hand, but it is also appended to by the migration:create command.\n// It's important that every migration is exported from here with the proper name. We'd simplify\n// this with kysely's FileMigrationProvider, but it doesn't play nicely with the build process.\n\nexport * as _20231219T205730722Z from './20231219T205730722Z-init.js'\nexport * as _20240116T085607200Z from './20240116T085607200Z-communication-template.js'\nexport * as _20240201T051104136Z from './20240201T051104136Z-mod-event-blobs.js'\nexport * as _20240208T213404429Z from './20240208T213404429Z-add-tags-column-to-moderation-subject.js'\nexport * as _20240228T003647759Z from './20240228T003647759Z-add-label-sigs.js'\nexport * as _20240408T192432676Z from './20240408T192432676Z-mute-reporting.js'\nexport * as _20240506T225055595Z from './20240506T225055595Z-message-subject.js'\nexport * as _20240430T211332580Z from './20240521T211332580Z-member.js'\nexport * as _20240814T003647759Z from './20240814T003647759Z-event-created-at-index.js'\nexport * as _20240903T205730722Z from './20240903T205730722Z-add-template-lang.js'\nexport * as _20240904T205730722Z from './20240904T205730722Z-add-subject-did-index.js'\nexport * as _20241001T205730722Z from './20241001T205730722Z-subject-status-review-state-index.js'\nexport * as _20241008T205730722Z from './20241008T205730722Z-sets.js'\nexport * as _20241018T205730722Z from './20241018T205730722Z-setting.js'\nexport * as _20241026T205730722Z from './20241026T205730722Z-add-hosting-status-to-subject-status.js'\nexport * as _20241220T144630860Z from './20241220T144630860Z-stats-materialized-views.js'\nexport * as _20250204T003647759Z from './20250204T003647759Z-add-subject-priority-score.js'\nexport * as _20250211T003647759Z from './20250211T003647759Z-add-reporter-stats-index.js'\nexport * as _20250211T132135150Z from './20250211T132135150Z-moderation-event-message-partial-idx.js'\nexport * as _20250221T132135150Z from './20250221T132135150Z-member-details.js'\nexport * as _20250404T201720309Z from './20250404T201720309Z-subject-status-sort-idxs.js'\nexport * as _20250415T201720309Z from './20250415T201720309Z-verification.js'\nexport * as _20250417T201720309Z from './20250417T201720309Z-firehose-cursor.js'\nexport * as _20250609T110704000Z from './20250609T110704000Z-safelink.js'\nexport * as _20250618T180246000Z from './20250618T180246000Z-add-mod-tool-to-moderation-event.js'\nexport * as _20250701T000000000Z from './20250701T000000000Z-add-age-assurance-state.js'\nexport * as _20250715T000000000Z from './20250715T000000000Z-add-mod-event-external-id.js'\nexport * as _20250718T150931000Z from './20250718T150931000Z-update-appeal-reason-stats.js'\nexport * as _20250813T000000000Z from './20250813T000000000Z-mod-tool-batch-id-index.js'\nexport * as _20250923T000000000Z from './20250923T000000000Z-scheduled-actions.js'\nexport * as _20251008T120000000Z from './20251008T120000000Z-add-strike-system.js'\nexport * as _20260210T154806448Z from './20260210T154806448Z-mod-event-created-by-indexes.js'\nexport * as _20260219T164523000Z from './20260219T164523000Z-create-report-table.js'\nexport * as _20260219T165302248Z from './20260219T165302248Z-moderator-assignment.js'\nexport * as _20260225T000000000Z from './20260225T000000000Z-add-report-queue-table.js'\nexport * as _20260313T000000000Z from './20260313T000000000Z-add-report-activity-table.js'\nexport * as _20260318T152058935Z from './20260318T152058935Z-add-report-stat.js'\nexport * as _20260428T000000000Z from './20260428T000000000Z-add-expiring-tag-table.js'\nexport * as _20260513T202941104Z from './20260513T202941104Z-add-subject-convo-id.js'\nexport * as _20260602T120000000Z from './20260602T120000000Z-add-report-activity-created-index.js'\nexport * as _20260617T210022765Z from './20260617T210022765Z-add-report-isautomated.js'\nexport * as _20260720T000000000Z from './20260720T000000000Z-add-convo-subjects-to-stats-views.js'\nexport * as _20260731T000000000Z from './20260731T000000000Z-add-recommended-policies-to-report-queue.js'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db/migrations/index.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,gGAAgG;AAChG,+FAA+F;AAE/F,OAAO,KAAK,oBAAoB,MAAM,+BAA+B,CAAA;AACrE,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,0CAA0C,CAAA;AAChF,OAAO,KAAK,oBAAoB,MAAM,gEAAgE,CAAA;AACtG,OAAO,KAAK,oBAAoB,MAAM,yCAAyC,CAAA;AAC/E,OAAO,KAAK,oBAAoB,MAAM,yCAAyC,CAAA;AAC/E,OAAO,KAAK,oBAAoB,MAAM,0CAA0C,CAAA;AAChF,OAAO,KAAK,oBAAoB,MAAM,iCAAiC,CAAA;AACvE,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,4CAA4C,CAAA;AAClF,OAAO,KAAK,oBAAoB,MAAM,gDAAgD,CAAA;AACtF,OAAO,KAAK,oBAAoB,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK,oBAAoB,MAAM,+BAA+B,CAAA;AACrE,OAAO,KAAK,oBAAoB,MAAM,kCAAkC,CAAA;AACxE,OAAO,KAAK,oBAAoB,MAAM,+DAA+D,CAAA;AACrG,OAAO,KAAK,oBAAoB,MAAM,mDAAmD,CAAA;AACzF,OAAO,KA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oBAAoB,MAAM,mEAAmE,CAAA;AACzG,OAAO,KAAK,oBAAoB,MAAM,sDAAsD,CAAA;AAC5F,OAAO,KAAK,oBAAoB,MAAM,qDAAqD,CAAA;AAC3F,OAAO,KAAK,oBAAoB,MAAM,uCAAuC,CAAA","sourcesContent":["// NOTE this file can be edited by hand, but it is also appended to by the migration:create command.\n// It's important that every migration is exported from here with the proper name. We'd simplify\n// this with kysely's FileMigrationProvider, but it doesn't play nicely with the build process.\n\nexport * as _20231219T205730722Z from './20231219T205730722Z-init.js'\nexport * as _20240116T085607200Z from './20240116T085607200Z-communication-template.js'\nexport * as _20240201T051104136Z from './20240201T051104136Z-mod-event-blobs.js'\nexport * as _20240208T213404429Z from './20240208T213404429Z-add-tags-column-to-moderation-subject.js'\nexport * as _20240228T003647759Z from './20240228T003647759Z-add-label-sigs.js'\nexport * as _20240408T192432676Z from './20240408T192432676Z-mute-reporting.js'\nexport * as _20240506T225055595Z from './20240506T225055595Z-message-subject.js'\nexport * as _20240430T211332580Z from './20240521T211332580Z-member.js'\nexport * as _20240814T003647759Z from './20240814T003647759Z-event-created-at-index.js'\nexport * as _20240903T205730722Z from './20240903T205730722Z-add-template-lang.js'\nexport * as _20240904T205730722Z from './20240904T205730722Z-add-subject-did-index.js'\nexport * as _20241001T205730722Z from './20241001T205730722Z-subject-status-review-state-index.js'\nexport * as _20241008T205730722Z from './20241008T205730722Z-sets.js'\nexport * as _20241018T205730722Z from './20241018T205730722Z-setting.js'\nexport * as _20241026T205730722Z from './20241026T205730722Z-add-hosting-status-to-subject-status.js'\nexport * as _20241220T144630860Z from './20241220T144630860Z-stats-materialized-views.js'\nexport * as _20250204T003647759Z from './20250204T003647759Z-add-subject-priority-score.js'\nexport * as _20250211T003647759Z from './20250211T003647759Z-add-reporter-stats-index.js'\nexport * as _20250211T132135150Z from './20250211T132135150Z-moderation-event-message-partial-idx.js'\nexport * as _20250221T132135150Z from './20250221T132135150Z-member-details.js'\nexport * as _20250404T201720309Z from './20250404T201720309Z-subject-status-sort-idxs.js'\nexport * as _20250415T201720309Z from './20250415T201720309Z-verification.js'\nexport * as _20250417T201720309Z from './20250417T201720309Z-firehose-cursor.js'\nexport * as _20250609T110704000Z from './20250609T110704000Z-safelink.js'\nexport * as _20250618T180246000Z from './20250618T180246000Z-add-mod-tool-to-moderation-event.js'\nexport * as _20250701T000000000Z from './20250701T000000000Z-add-age-assurance-state.js'\nexport * as _20250715T000000000Z from './20250715T000000000Z-add-mod-event-external-id.js'\nexport * as _20250718T150931000Z from './20250718T150931000Z-update-appeal-reason-stats.js'\nexport * as _20250813T000000000Z from './20250813T000000000Z-mod-tool-batch-id-index.js'\nexport * as _20250923T000000000Z from './20250923T000000000Z-scheduled-actions.js'\nexport * as _20251008T120000000Z from './20251008T120000000Z-add-strike-system.js'\nexport * as _20260210T154806448Z from './20260210T154806448Z-mod-event-created-by-indexes.js'\nexport * as _20260219T164523000Z from './20260219T164523000Z-create-report-table.js'\nexport * as _20260219T165302248Z from './20260219T165302248Z-moderator-assignment.js'\nexport * as _20260225T000000000Z from './20260225T000000000Z-add-report-queue-table.js'\nexport * as _20260313T000000000Z from './20260313T000000000Z-add-report-activity-table.js'\nexport * as _20260318T152058935Z from './20260318T152058935Z-add-report-stat.js'\nexport * as _20260428T000000000Z from './20260428T000000000Z-add-expiring-tag-table.js'\nexport * as _20260513T202941104Z from './20260513T202941104Z-add-subject-convo-id.js'\nexport * as _20260602T120000000Z from './20260602T120000000Z-add-report-activity-created-index.js'\nexport * as _20260617T210022765Z from './20260617T210022765Z-add-report-isautomated.js'\nexport * as _20260720T000000000Z from './20260720T000000000Z-add-convo-subjects-to-stats-views.js'\nexport * as _20260731T000000000Z from './20260731T000000000Z-add-recommended-policies-to-report-queue.js'\nexport * as _20260810T000000000Z from './20260810T000000000Z-add-report-stats-components.js'\nexport * as _20260922T153505234Z from './20260922T153505234Z-add-report-closed-at-index.js'\nexport * as _20260928T000000000Z from './20260928T000000000Z-inbox-appeal.js'\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../../src/db/schema/report.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["import type { Generated } from 'kysely'\nimport type { DatetimeString, DidString } from '@atproto/lex'\n\nexport const reportTableName = 'report'\n\nexport interface Report {\n id: Generated<number>\n eventId: number // References moderation_event.id\n queueId: number | null // NULL = not yet assigned, -1 = no matching queue\n queuedAt: DatetimeString | null\n actionEventIds: number[] | null //
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../../src/db/schema/report.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["import type { Generated } from 'kysely'\nimport type { DatetimeString, DidString } from '@atproto/lex'\n\nexport const reportTableName = 'report'\n\nexport interface Report {\n id: Generated<number>\n eventId: number // References moderation_event.id\n queueId: number | null // NULL = not yet assigned, -1 = no matching queue\n queuedAt: DatetimeString | null\n actionEventIds: number[] | null // Event IDs in append order (most recently linked last)\n actionNote: string | null\n isMuted: boolean\n isAutomated: boolean // Denormalized from moderation_event.modTool.meta.isAutomated\n status: string // 'open', 'closed', 'escalated', 'queued', 'assigned'\n reportType: string // Denormalized from moderation_event.meta.reportType\n did: DidString // Denormalized from moderation_event.subjectDid\n recordPath: string // '' = account/message/conversation, 'collection/rkey' = record\n subjectMessageId: string | null // Denormalized from moderation_event.subjectMessageId\n subjectConvoId: string | null // Denormalized from moderation_event.subjectConvoId\n createdAt: DatetimeString\n updatedAt: DatetimeString\n assignedTo: DidString | null // DID of permanently assigned moderator, null if unassigned\n assignedAt: DatetimeString | null // When the permanent assignment was created\n closedAt: DatetimeString | null\n}\n\nexport type PartialDB = {\n [reportTableName]: Report\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report_queue.d.ts","sourceRoot":"","sources":["../../../src/db/schema/report_queue.ts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EAAE,CAAA;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,mBAAmB,EAAE,MAAM,EAAE,CAAA;IAC7B,iBAAiB,EAAE,MAAM,EAAE,CAAA;IAC3B,SAAS,EAAE,SAAS,GAAG,aAAa,CAAA;IACpC,SAAS,EAAE,cAAc,CAAA;IACzB,SAAS,EAAE,cAAc,CAAA;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,oBAAoB,CAAC,EAAE,WAAW,CAAA;CACpC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report_queue.js","sourceRoot":"","sources":["../../../src/db/schema/report_queue.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAc,CAAA","sourcesContent":["import type { Generated } from 'kysely'\nimport type { DatetimeString, DidString, NsidString } from '@atproto/lex'\n\nexport const reportQueueTableName = 'report_queue'\n\nexport interface ReportQueue {\n id: Generated<number>\n name: string\n subjectTypes: string[] // ['account'] or ['record'] or ['account', 'record']\n collection: NsidString | null // Collection name (e.g., 'app.bsky.feed.post'), NULL for accounts\n reportTypes: string[] // Array of report reason types (fully qualified NSIDs)\n description: string | null // Optional description of the queue\n recommendedPolicies: string[] // Policy keys recommended for reports in this queue\n createdBy: DidString | 'admin_token' // DID of moderator who created this queue\n createdAt: DatetimeString\n updatedAt: DatetimeString\n enabled: boolean\n deletedAt: string | null // NULL = active, timestamp = soft-deleted\n}\n\nexport type PartialDB = {\n [reportQueueTableName]: ReportQueue\n}\n"]}
|
|
1
|
+
{"version":3,"file":"report_queue.js","sourceRoot":"","sources":["../../../src/db/schema/report_queue.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAc,CAAA","sourcesContent":["import type { Generated } from 'kysely'\nimport type { DatetimeString, DidString, NsidString } from '@atproto/lex'\n\nexport const reportQueueTableName = 'report_queue'\n\nexport interface ReportQueue {\n id: Generated<number>\n name: string\n subjectTypes: string[] // ['account'] or ['record'] or ['account', 'record']\n collection: NsidString | null // Collection name (e.g., 'app.bsky.feed.post'), NULL for accounts\n reportTypes: string[] // Array of report reason types (fully qualified NSIDs)\n description: string | null // Optional description of the queue\n recommendedPolicies: string[] // Policy keys recommended for reports in this queue\n recommendedLabels: string[] // Label values recommended for this queue and used for appeal routing\n createdBy: DidString | 'admin_token' // DID of moderator who created this queue\n createdAt: DatetimeString\n updatedAt: DatetimeString\n enabled: boolean\n deletedAt: string | null // NULL = active, timestamp = soft-deleted\n}\n\nexport type PartialDB = {\n [reportQueueTableName]: ReportQueue\n}\n"]}
|
|
@@ -15,10 +15,20 @@ export interface ReportStat {
|
|
|
15
15
|
moderatorDid: DidString | null;
|
|
16
16
|
inboundCount: number | null;
|
|
17
17
|
pendingCount: number | null;
|
|
18
|
-
actionedCount: number | null;
|
|
19
18
|
escalatedCount: number | null;
|
|
19
|
+
actionedCount: number | null;
|
|
20
20
|
actionRate: number | null;
|
|
21
|
+
labelActionCount: number | null;
|
|
22
|
+
tagActionCount: number | null;
|
|
23
|
+
takedownActionCount: number | null;
|
|
24
|
+
acknowledgedCount: number | null;
|
|
25
|
+
closedCount: number | null;
|
|
21
26
|
avgHandlingTimeSec: number | null;
|
|
27
|
+
ahtDurationSec: number | null;
|
|
28
|
+
ahtSampleCount: number | null;
|
|
29
|
+
resolutionDurationSec: number | null;
|
|
30
|
+
resolutionSampleCount: number | null;
|
|
31
|
+
avgResolutionTimeSec: number | null;
|
|
22
32
|
}
|
|
23
33
|
export type PartialDB = {
|
|
24
34
|
[reportStatTableName]: ReportStat;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report_stat.d.ts","sourceRoot":"","sources":["../../../src/db/schema/report_stat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;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MAAM,GAAG,IAAI,CAAA;IAG7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAG1B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAG7B,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,mBAAmB,CAAC,EAAE,UAAU,CAAA;CAClC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report_stat.js","sourceRoot":"","sources":["../../../src/db/schema/report_stat.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAAA","sourcesContent":["import type { Generated } from 'kysely'\nimport type { DatetimeString, DidString } from '@atproto/lex'\n\n/**\n * A calendar day in `YYYY-MM-DD` form. Typed as a template literal so it\n * composes into a {@link DatetimeString} without a cast.\n */\nexport type DateString = `${string}-${string}-${string}`\n\nexport const reportStatTableName = 'report_stat'\n\nexport interface ReportStat {\n // metadata\n id: Generated<number>\n computedAt: DatetimeString // When this snapshot was last computed\n\n // group\n date: DateString // ISO date e.g. '2026-04-15' — the calendar day this snapshot covers\n queueId: number | null // NULL = aggregate across all queues\n reportTypes: string[] | null // NULL = aggregate across all report types\n moderatorDid: DidString | null // NULL = aggregate, non-null = per-moderator\n\n //
|
|
1
|
+
{"version":3,"file":"report_stat.js","sourceRoot":"","sources":["../../../src/db/schema/report_stat.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAAA","sourcesContent":["import type { Generated } from 'kysely'\nimport type { DatetimeString, DidString } from '@atproto/lex'\n\n/**\n * A calendar day in `YYYY-MM-DD` form. Typed as a template literal so it\n * composes into a {@link DatetimeString} without a cast.\n */\nexport type DateString = `${string}-${string}-${string}`\n\nexport const reportStatTableName = 'report_stat'\n\nexport interface ReportStat {\n // metadata\n id: Generated<number>\n computedAt: DatetimeString // When this snapshot was last computed\n\n // group\n date: DateString // ISO date e.g. '2026-04-15' — the calendar day this snapshot covers\n queueId: number | null // NULL = aggregate across all queues\n reportTypes: string[] | null // NULL = aggregate across all report types\n moderatorDid: DidString | null // NULL = aggregate, non-null = per-moderator\n\n // inbound\n inboundCount: number | null // Reports received during this calendar day\n\n // unresolved\n pendingCount: number | null // Reports with status != 'closed' at time of computation\n escalatedCount: number | null // Reports escalated during this calendar day\n\n // resolved\n actionedCount: number | null // Current closures whose last action was enforcement\n actionRate: number | null // actionedCount / closedCount * 100\n labelActionCount: number | null // Current closures whose last action was label\n tagActionCount: number | null // Current closures whose last action was tag\n takedownActionCount: number | null // Current closures whose last action was takedown\n acknowledgedCount: number | null // Current closures without a last enforcement action\n closedCount: number | null // Current reports with closedAt in this calendar day\n\n // handling time\n avgHandlingTimeSec: number | null // Average time from assignment to close, in seconds\n ahtDurationSec: number | null // Sum of assignment-to-close durations\n ahtSampleCount: number | null // Assigned closed-report samples in ahtDurationSec\n\n // resolution time\n resolutionDurationSec: number | null // Sum of creation-to-close durations\n resolutionSampleCount: number | null // Closed-report samples in resolutionDurationSec\n avgResolutionTimeSec: number | null // Average time from creation to close, in seconds\n}\n\nexport type PartialDB = {\n [reportStatTableName]: ReportStat\n}\n"]}
|