fix(reporting): update task logging queries for accuracy

- Modified SQL queries in the ReportingMembersController to correctly reference user IDs from the team_members table, ensuring accurate time logged calculations.
- Added a check in the on_quick_assign_or_remove command to handle cases where no team member is found, improving error handling and logging.
This commit is contained in:
chamiakJ
2025-07-29 19:08:52 +05:30
parent 8830af2cbb
commit 8d17490f7e
2 changed files with 8 additions and 3 deletions

View File

@@ -265,8 +265,8 @@ export default class ReportingMembersController extends ReportingControllerBase
(SELECT color_code FROM project_phases WHERE id = (SELECT phase_id FROM task_phase WHERE task_id = t.id)) AS phase_color,
(total_minutes * 60) AS total_minutes,
(SELECT SUM(time_spent) FROM task_work_log WHERE task_id = t.id AND ta.team_member_id = $1) AS time_logged,
((SELECT SUM(time_spent) FROM task_work_log WHERE task_id = t.id AND ta.team_member_id = $1) - (total_minutes * 60)) AS overlogged_time`;
(SELECT SUM(time_spent) FROM task_work_log twl WHERE twl.task_id = t.id AND twl.user_id = (SELECT user_id FROM team_members WHERE id = $1)) AS time_logged,
((SELECT SUM(time_spent) FROM task_work_log twl WHERE twl.task_id = t.id AND twl.user_id = (SELECT user_id FROM team_members WHERE id = $1)) - (total_minutes * 60)) AS overlogged_time`;
}
protected static getActivityLogsOverdue(key: string, dateRange: string[]) {

View File

@@ -75,7 +75,7 @@ export async function on_quick_assign_or_remove(_io: Server, socket: Socket, dat
assign_type: type
});
if (userId !== assignment.user_id) {
if (assignment && userId !== assignment.user_id) {
NotificationsService.createTaskUpdate(
type,
userId as string,
@@ -109,6 +109,11 @@ export async function assignMemberIfNot(taskId: string, userId: string, teamId:
const result = await db.query(q, [taskId, userId, teamId]);
const [data] = result.rows;
if (!data) {
log_error(new Error(`No team member found for userId: ${userId}, teamId: ${teamId}`));
return;
}
const body = {
team_member_id: data.team_member_id,
project_id: data.project_id,