beardofedu / beardofedu/copilot-cli-fun-times
feat: GET /tasks/stats endpoint
- Dominant language
- JavaScript
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
Add a `GET /tasks/stats` endpoint that returns aggregate statistics about the current task list, including counts by priority, overall completion rate, and number of overdue tasks.
## Motivation
Dashboards and reporting tools need summary data without fetching and processing every task on the client side. A dedicated stats endpoint is a clean, efficient way to expose this information.
## Proposed Behavior
`GET /tasks/stats` returns a JSON object such as:
```json
{
"total": 10,
"completed": 4,
"completionRate": 0.4,
"overdue": 2,
"byPriority": {
"1": 3,
"2": 4,
"3": 3
}
}
```
- `overdue` counts tasks where `dueDate` is in the past and `completed` is `false`
- `completionRate` is `completed / total` (0 if total is 0)
- `byPriority` counts all tasks (completed and incomplete) per priority level
## Acceptance Criteria
- [ ] `GET /tasks/stats` returns HTTP 200 with the stats object
- [ ] `total`, `completed`, `completionRate`, `overdue`, and `byPriority` fields are all present
- [ ] `completionRate` is 0 when there are no tasks
- [ ] `overdue` correctly counts only incomplete past-due tasks
- [ ] Stats logic extracted into a `computeStats(tasks)` utility function in `utils.js`
- [ ] Unit tests cover normal case, empty task list, and zero-completion edge case
- [ ] Route is registered before `/tasks/:id` to avoid `id` param conflict
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the existing task routes, especially `/tasks/:id`, and the route registration order. Add the `computeStats(tasks)` utility in `utils.js`, register `GET /tasks/stats` before the parameterized route, and inspect the existing test setup. Done means the endpoint returns all specified fields and tests cover normal, empty, and zero-completion cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100