Improve job status notifications
This commit is contained in:
@@ -18,6 +18,7 @@ describe('sqlite schema compatibility bootstrap', () => {
|
||||
applyMigration(client, '0001_glossy_statement_snapshots.sql');
|
||||
applyMigration(client, '0002_workflow_task_projection_metadata.sql');
|
||||
applyMigration(client, '0003_task_stage_event_timeline.sql');
|
||||
applyMigration(client, '0009_task_notification_context.sql');
|
||||
|
||||
expect(__dbInternals.hasColumn(client, 'watchlist_item', 'category')).toBe(false);
|
||||
expect(__dbInternals.hasColumn(client, 'watchlist_item', 'status')).toBe(false);
|
||||
@@ -38,6 +39,8 @@ describe('sqlite schema compatibility bootstrap', () => {
|
||||
expect(__dbInternals.hasColumn(client, 'holding', 'company_name')).toBe(true);
|
||||
expect(__dbInternals.hasTable(client, 'filing_taxonomy_snapshot')).toBe(true);
|
||||
expect(__dbInternals.hasTable(client, 'filing_taxonomy_fact')).toBe(true);
|
||||
expect(__dbInternals.hasColumn(client, 'task_run', 'stage_context')).toBe(true);
|
||||
expect(__dbInternals.hasColumn(client, 'task_stage_event', 'stage_context')).toBe(true);
|
||||
expect(__dbInternals.hasTable(client, 'research_journal_entry')).toBe(true);
|
||||
expect(__dbInternals.hasTable(client, 'search_document')).toBe(true);
|
||||
expect(__dbInternals.hasTable(client, 'search_chunk')).toBe(true);
|
||||
|
||||
@@ -396,6 +396,7 @@ function ensureLocalSqliteSchema(client: Database) {
|
||||
const missingTaskColumns: Array<{ name: string; sql: string }> = [
|
||||
{ name: 'stage', sql: "ALTER TABLE `task_run` ADD `stage` text NOT NULL DEFAULT 'queued';" },
|
||||
{ name: 'stage_detail', sql: 'ALTER TABLE `task_run` ADD `stage_detail` text;' },
|
||||
{ name: 'stage_context', sql: 'ALTER TABLE `task_run` ADD `stage_context` text;' },
|
||||
{ name: 'resource_key', sql: 'ALTER TABLE `task_run` ADD `resource_key` text;' },
|
||||
{ name: 'notification_read_at', sql: 'ALTER TABLE `task_run` ADD `notification_read_at` text;' },
|
||||
{ name: 'notification_silenced_at', sql: 'ALTER TABLE `task_run` ADD `notification_silenced_at` text;' }
|
||||
@@ -412,6 +413,12 @@ function ensureLocalSqliteSchema(client: Database) {
|
||||
applySqlFile(client, '0003_task_stage_event_timeline.sql');
|
||||
}
|
||||
|
||||
if (hasTable(client, 'task_stage_event') && !hasColumn(client, 'task_stage_event', 'stage_context')) {
|
||||
client.exec('ALTER TABLE `task_stage_event` ADD `stage_context` text;');
|
||||
}
|
||||
|
||||
client.exec('CREATE INDEX IF NOT EXISTS `task_user_updated_idx` ON `task_run` (`user_id`, `updated_at`);');
|
||||
|
||||
if (hasTable(client, 'watchlist_item')) {
|
||||
const missingWatchlistColumns: Array<{ name: string; sql: string }> = [
|
||||
{ name: 'category', sql: 'ALTER TABLE `watchlist_item` ADD `category` text;' },
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
text,
|
||||
uniqueIndex
|
||||
} from 'drizzle-orm/sqlite-core';
|
||||
import type { TaskStageContext } from '@/lib/types';
|
||||
|
||||
type FilingMetrics = {
|
||||
revenue: number | null;
|
||||
@@ -520,6 +521,7 @@ export const taskRun = sqliteTable('task_run', {
|
||||
status: text('status').$type<'queued' | 'running' | 'completed' | 'failed'>().notNull(),
|
||||
stage: text('stage').notNull(),
|
||||
stage_detail: text('stage_detail'),
|
||||
stage_context: text('stage_context', { mode: 'json' }).$type<TaskStageContext | null>(),
|
||||
resource_key: text('resource_key'),
|
||||
notification_read_at: text('notification_read_at'),
|
||||
notification_silenced_at: text('notification_silenced_at'),
|
||||
@@ -535,6 +537,7 @@ export const taskRun = sqliteTable('task_run', {
|
||||
finished_at: text('finished_at')
|
||||
}, (table) => ({
|
||||
taskUserCreatedIndex: index('task_user_created_idx').on(table.user_id, table.created_at),
|
||||
taskUserUpdatedIndex: index('task_user_updated_idx').on(table.user_id, table.updated_at),
|
||||
taskStatusIndex: index('task_status_idx').on(table.status),
|
||||
taskUserResourceStatusIndex: index('task_user_resource_status_idx').on(
|
||||
table.user_id,
|
||||
@@ -552,6 +555,7 @@ export const taskStageEvent = sqliteTable('task_stage_event', {
|
||||
user_id: text('user_id').notNull().references(() => user.id, { onDelete: 'cascade' }),
|
||||
stage: text('stage').notNull(),
|
||||
stage_detail: text('stage_detail'),
|
||||
stage_context: text('stage_context', { mode: 'json' }).$type<TaskStageContext | null>(),
|
||||
status: text('status').$type<'queued' | 'running' | 'completed' | 'failed'>().notNull(),
|
||||
created_at: text('created_at').notNull()
|
||||
}, (table) => ({
|
||||
|
||||
Reference in New Issue
Block a user