Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mapped by others and validated by others query in user detailed … #6754

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions backend/services/users/user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,20 +422,18 @@ async def get_detailed_stats(username: str, db: Database) -> UserStatsDTO:
SELECT project_id, task_id
FROM task_history
WHERE user_id = :user_id
AND action_text IN ('VALIDATED', 'INVALIDATED', 'MAPPED')
)
AND user_id != :user_id
AND action_text IN ('VALIDATED', 'INVALIDATED')
GROUP BY action_text
)
SELECT
CAST(COALESCE(SUM(CASE WHEN u.action_text = 'VALIDATED' THEN u.action_count ELSE 0 END), 0) AS INTEGER) AS tasks_validated,
CAST(COALESCE(SUM(CASE WHEN u.action_text = 'INVALIDATED' THEN u.action_count ELSE 0 END), 0) AS INTEGER) AS tasks_invalidated,
CAST(COALESCE(SUM(CASE WHEN u.action_text = 'MAPPED' THEN u.action_count ELSE 0 END), 0) AS INTEGER) AS tasks_mapped,
CAST(COALESCE(SUM(CASE WHEN o.action_text = 'VALIDATED' THEN o.action_count ELSE 0 END), 0) AS INTEGER) AS tasks_validated_by_others,
CAST(COALESCE(SUM(CASE WHEN o.action_text = 'INVALIDATED' THEN o.action_count ELSE 0 END), 0) AS INTEGER) AS tasks_invalidated_by_others
FROM user_actions u
LEFT JOIN others_actions o
ON u.action_text = o.action_text;
CAST(COALESCE((SELECT SUM(action_count) FROM user_actions WHERE action_text = 'VALIDATED'), 0) AS INTEGER) AS tasks_validated,
CAST(COALESCE((SELECT SUM(action_count) FROM user_actions WHERE action_text = 'INVALIDATED'), 0) AS INTEGER) AS tasks_invalidated,
CAST(COALESCE((SELECT SUM(action_count) FROM user_actions WHERE action_text = 'MAPPED'), 0) AS INTEGER) AS tasks_mapped,
CAST(COALESCE((SELECT SUM(action_count) FROM others_actions WHERE action_text = 'VALIDATED'), 0) AS INTEGER) AS tasks_validated_by_others,
CAST(COALESCE((SELECT SUM(action_count) FROM others_actions WHERE action_text = 'INVALIDATED'), 0) AS INTEGER) AS tasks_invalidated_by_others;
"""
stats_result = await db.fetch_one(
query=stats_query, values={"user_id": user_id}
Expand Down