Skip to content

Latest commit

History

History
88 lines (74 loc) 路 2.05 KB

File metadata and controls

88 lines (74 loc) 路 2.05 KB

Task 2: Create the "Statistics" Feature

馃幆 Objective

Create a REST endpoint /api/statistics that provides insights about Todo items.

馃搵 Requirements

1. API Endpoint

  • Base path: /api/statistics

  • Support query parameters:

    • from - Start date (e.g., 2023-01-01)
    • to - End date (e.g., 2023-12-31)
    • format - Response format (summary or detailed)
    • either from, to, or both can pe provided

2. Statistics to Include

  • Total number of todos
  • Number of completed todos
  • Number of pending todos
  • Todos per user breakdown

3. Technical Requirements

4. Summary Sample Response

{
  "totalTodos": 10,
  "completedTodos": 7,
  "pendingTodos": 3,
  "userStats": {
    "user1": 5,
    "user2": 3,
    "user3": 2
  }
}

5. Detailed Sample Response

{
  "totalTodos": 10,
  "completedTodos": 7,
  "pendingTodos": 3,
  "userStats": {
    "user1": 5,
    "user2": 3,
    "user3": 2
  },
  "todos": {
    "completed": [
      {
        "id": "1",
        "title": "Deploy to production",
        "createdBy": "user1",
        "createdAt": "2024-03-15T10:30:00Z",
        "completedAt": "2024-03-15T14:20:00Z"
      }
      // ... more completed todos
    ],
    "pending": [
      {
        "id": "8",
        "title": "Review pull request",
        "createdBy": "user2",
        "createdAt": "2024-03-15T09:00:00Z"
      }
      // ... more pending todos
    ]
  }
}