Отслеживание просмотров задач: task_views, POST /api/tasks/:id/view и обновление /api/home/recent

This commit is contained in:
2026-08-24 15:40:30 +03:00
parent 74abd8fad5
commit a4eaf65915
7 changed files with 107 additions and 1 deletions

View File

@@ -3123,6 +3123,24 @@ export const taskInboxHidden = pgTable("task_inbox_hidden", {
export type TaskInboxHidden = typeof taskInboxHidden.$inferSelect;
export type InsertTaskInboxHidden = typeof taskInboxHidden.$inferInsert;
// =====================
// Task Views (последние просмотренные задачи пользователем)
// =====================
export const taskViews = pgTable("task_views", {
id: serial("id").primaryKey(),
taskId: integer("task_id").notNull().references(() => tasks.id, { onDelete: "cascade" }),
userId: integer("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
organizationId: integer("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
viewedAt: timestamp("viewed_at").defaultNow(),
}, (table) => ({
uniqueTaskUser: unique("task_views_task_user_key").on(table.organizationId, table.userId, table.taskId),
userViewedAtIdx: index("task_views_user_viewed_at_idx").on(table.organizationId, table.userId, table.viewedAt.desc()),
taskIdx: index("task_views_task_idx").on(table.taskId),
}));
export type TaskView = typeof taskViews.$inferSelect;
export type InsertTaskView = typeof taskViews.$inferInsert;
// =====================
// RAG Embeddings (векторная память для AI-агентов)
// =====================