fix: show all assigned tasks on leader dashboard
This commit is contained in:
1 parent
9d1a6b4379
commit
03d01315a9
4 files changed
+30
-14
No files matched your search
@@ -4736,13 +4736,14 @@ export class TaskService {
|
||||
const status = options.status || 'all';
|
||||
const params: unknown[] = [context.organizationId, from.toISOString(), to.toISOString()];
|
||||
let where = `t.organization_id = $1
|
||||
AND t.source = 'manual'
|
||||
AND t.assigned_user_id IS NOT NULL
|
||||
AND t.source IN ('manual', 'agentbus')
|
||||
AND t.created_at >= $2::timestamptz
|
||||
AND t.created_at < $3::timestamptz`;
|
||||
const actorUserId = text(options.actorUserId).trim();
|
||||
if (actorUserId) {
|
||||
params.push(actorUserId);
|
||||
where += ` AND t.created_by = $${params.length}`;
|
||||
where += ` AND t.assigned_user_id = $${params.length}`;
|
||||
}
|
||||
const businessRouteId = text(options.businessRouteId).trim();
|
||||
if (businessRouteId && businessRouteId !== 'unclassified' && !operationsDashboardTypeById(businessRouteId)) {
|
||||
@@ -4767,8 +4768,8 @@ export class TaskService {
|
||||
];
|
||||
const taskBaseSelect = `t.id, t.task_id, t.status, t.business_route_id, t.archived_at,
|
||||
t.created_at, t.updated_at, t.operation,
|
||||
creator.id AS actor_id, creator.username AS actor_username,
|
||||
creator.role AS actor_role, creator.is_active AS actor_is_active,
|
||||
assignee.id AS actor_id, assignee.username AS actor_username,
|
||||
assignee.role AS actor_role, assignee.is_active AS actor_is_active,
|
||||
to_char(timezone('Asia/Shanghai', t.created_at), 'YYYY-MM-DD') AS business_day`;
|
||||
const taskDetailSelect = `${taskBaseSelect},
|
||||
t.original_text_ciphertext, t.message, t.success_receipt, t.success_receipt_at,
|
||||
@@ -4824,7 +4825,7 @@ export class TaskService {
|
||||
'page_details',
|
||||
`SELECT ${taskDetailSelect}
|
||||
FROM tasks t
|
||||
LEFT JOIN users creator ON creator.id = t.created_by
|
||||
LEFT JOIN users assignee ON assignee.id = t.assigned_user_id
|
||||
WHERE t.organization_id = $1
|
||||
AND t.id = ANY($2::uuid[])`,
|
||||
[context.organizationId, taskRowIds]
|
||||
@@ -4836,7 +4837,7 @@ export class TaskService {
|
||||
'candidates',
|
||||
`SELECT ${search ? taskSearchSelect : taskCandidateSelect}
|
||||
FROM tasks t
|
||||
LEFT JOIN users creator ON creator.id = t.created_by
|
||||
LEFT JOIN users assignee ON assignee.id = t.assigned_user_id
|
||||
WHERE ${where}
|
||||
ORDER BY t.created_at DESC, t.id DESC`,
|
||||
params
|
||||
@@ -5003,8 +5004,8 @@ export class TaskService {
|
||||
t.created_at, t.updated_at, t.success_receipt, t.success_receipt_at,
|
||||
t.error_summary, t.error_summary_at, t.execution_result,
|
||||
t.operation, t.parse_response,
|
||||
creator.id AS actor_id, creator.username AS actor_username,
|
||||
creator.role AS actor_role, creator.is_active AS actor_is_active,
|
||||
assignee.id AS actor_id, assignee.username AS actor_username,
|
||||
assignee.role AS actor_role, assignee.is_active AS actor_is_active,
|
||||
to_char(timezone('Asia/Shanghai', t.created_at), 'YYYY-MM-DD') AS business_day,
|
||||
(SELECT COUNT(*)::int
|
||||
FROM agent_session_messages input_message
|
||||
@@ -5013,8 +5014,11 @@ export class TaskService {
|
||||
AND input_message.role = 'user'
|
||||
AND input_message.input_source IS DISTINCT FROM 'reparse') AS input_turn_count
|
||||
FROM tasks t
|
||||
LEFT JOIN users creator ON creator.id = t.created_by
|
||||
WHERE t.organization_id = $1 AND t.task_id = $2 AND t.source = 'manual'`,
|
||||
LEFT JOIN users assignee ON assignee.id = t.assigned_user_id
|
||||
WHERE t.organization_id = $1
|
||||
AND t.task_id = $2
|
||||
AND t.assigned_user_id IS NOT NULL
|
||||
AND t.source IN ('manual', 'agentbus')`,
|
||||
[context.organizationId, taskId]
|
||||
);
|
||||
if (!target.rowCount) throw new TaskError('task_not_found', '任务不存在。', 404);
|
||||
|
||||
Reference in new issue
Block a user