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

RDISCROWD-7968 add n_gold_tasks to projectprogress API #1045

Merged
merged 3 commits into from
Feb 20, 2025
Merged

Conversation

n00rsy
Copy link

@n00rsy n00rsy commented Feb 18, 2025

Issue number of the reported bug or feature request: RDISCROWD-7968

Describe your changes
Add n_gold_tasks to /project/<id>/projectprogress API response
No changes to existing fields n_completed_tasks and n_tasks

Example:

Request:
GET /api/project/50/projectprogress

Response:

{
    "n_completed_tasks": 1,
    "n_tasks": 149,
    "n_gold_tasks": 2
}

Testing performed
Tested locally

@n00rsy n00rsy changed the title RDISCROWD-7968 RDISCROWD-7968 add n_gold_tasks to projectprogress API Feb 18, 2025
@coveralls
Copy link

coveralls commented Feb 18, 2025

Pull Request Test Coverage Report for Build 13420338534

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 94.153%

Totals Coverage Status
Change from base Build 13395416999: 0.0%
Covered Lines: 17585
Relevant Lines: 18677

💛 - Coveralls

@n00rsy n00rsy requested a review from kbecker42 February 19, 2025 16:35
@@ -449,10 +449,12 @@ def get_total_and_completed_task_count(self, project_id):
(SELECT COUNT(*) FROM task
WHERE task.project_id=:project_id AND task.state='completed') as n_completed,
(SELECT COUNT(task.id) AS n_tasks FROM task
WHERE task.project_id=:project_id AND calibration != 1) as n_tasks;
WHERE task.project_id=:project_id AND calibration != 1) as n_tasks,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this query be optimized to a single statement to obtain the counts?

SELECT  
    SUM(CASE WHEN task.state = 'completed' THEN 1 ELSE 0 END) AS n_completed,  
    SUM(CASE WHEN calibration != 1 THEN 1 ELSE 0 END) AS n_tasks,  
    SUM(CASE WHEN calibration = 1 THEN 1 ELSE 0 END) AS n_gold_tasks  
FROM task  
WHERE task.project_id = :project_id;  

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great suggestion! Implemented in f49f7e7

@n00rsy n00rsy merged commit e75f190 into main Feb 20, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants