清理旧消息和历史命名

This commit is contained in:
yml
2026-05-25 22:03:07 +08:00
parent e7aa194dde
commit 0caa38e690
41 changed files with 63 additions and 1044 deletions
+15 -15
View File
@@ -4,7 +4,7 @@ import type { PoolClient } from 'pg'
import type {
TaskCreateInput,
TaskListQueryInput,
TaskTencentContextPatch,
TaskRuntimeContextPatch,
TaskUpdatePatch,
} from '../types/repository-inputs.js'
import type {
@@ -14,7 +14,7 @@ import type {
type TaskQueryExecutor = (text: string, params?: unknown[]) => Promise<{ rows: unknown[] }>
type TencentBrowserContextRow = {
type TaskRuntimeContextRow = {
browser_session_id: string
login_type: string
nickname: string
@@ -52,7 +52,7 @@ const TASK_FIELDS = `
const TASK_JOINS = `
FROM fulfillment_tasks ft
LEFT JOIN claim_tokens ct ON ct.task_id = ft.id
LEFT JOIN tencent_browser_contexts ctx ON ctx.task_id = ft.id
LEFT JOIN task_runtime_contexts ctx ON ctx.task_id = ft.id
LEFT JOIN LATERAL (
SELECT
tib.inventory_item_id,
@@ -158,8 +158,8 @@ export async function createTask(input: TaskCreateInput): Promise<TaskRow | null
)
const taskId = Number(taskResult.rows[0]?.id || 0)
if (input.tencentContext) {
await upsertTencentBrowserContextWithClient(client, taskId, input.tencentContext, input.createdAt)
if (input.runtimeContext) {
await upsertTaskRuntimeContextWithClient(client, taskId, input.runtimeContext, input.createdAt)
}
return getTaskByIdWithExecutor(client.query.bind(client) as TaskQueryExecutor, taskId)
@@ -220,8 +220,8 @@ export async function updateTask(taskId: number | string, patch: TaskUpdatePatch
],
)
if (containsTencentPatch(patch)) {
await upsertTencentBrowserContextWithClient(client, Number(taskId), {
if (containsRuntimeContextPatch(patch)) {
await upsertTaskRuntimeContextWithClient(client, Number(taskId), {
browserSessionId: patch.browser_session_id,
loginType: patch.login_type,
nickname: patch.nickname,
@@ -310,7 +310,7 @@ export async function listTasks({
SELECT COUNT(*)::int AS total
FROM fulfillment_tasks ft
LEFT JOIN order_items oi ON oi.id = ft.order_item_id
LEFT JOIN tencent_browser_contexts ctx ON ctx.task_id = ft.id
LEFT JOIN task_runtime_contexts ctx ON ctx.task_id = ft.id
${whereClause}
`,
params,
@@ -333,14 +333,14 @@ export async function listTasks({
}
}
async function upsertTencentBrowserContextWithClient(
async function upsertTaskRuntimeContextWithClient(
client: PoolClient,
taskId: number | string,
patch: TaskTencentContextPatch = {},
patch: TaskRuntimeContextPatch = {},
timestamp: string | undefined,
): Promise<void> {
const currentResult = await client.query<TencentBrowserContextRow>(
'SELECT * FROM tencent_browser_contexts WHERE task_id = $1 LIMIT 1',
const currentResult = await client.query<TaskRuntimeContextRow>(
'SELECT * FROM task_runtime_contexts WHERE task_id = $1 LIMIT 1',
[Number(taskId)],
)
const current = currentResult.rows[0] || null
@@ -362,7 +362,7 @@ async function upsertTencentBrowserContextWithClient(
if (!current) {
await client.query(
`
INSERT INTO tencent_browser_contexts (
INSERT INTO task_runtime_contexts (
task_id,
browser_session_id,
login_type,
@@ -399,7 +399,7 @@ async function upsertTencentBrowserContextWithClient(
await client.query(
`
UPDATE tencent_browser_contexts
UPDATE task_runtime_contexts
SET
browser_session_id = $1,
login_type = $2,
@@ -444,7 +444,7 @@ async function getTaskByIdWithExecutor(
return (result.rows[0] as TaskRow | undefined) || null
}
function containsTencentPatch(patch: TaskUpdatePatch = {}): boolean {
function containsRuntimeContextPatch(patch: TaskUpdatePatch = {}): boolean {
return [
'browser_session_id',
'login_type',