Skip to content

Implement: Interest Group Task Activity Summary API #2658

Description

@DevWithPranav

Overview

μLearn is a gamified learning platform where students earn karma points by completing tasks. Each task belongs to an Interest Group (IG) (e.g., Web Development, AI/ML, Design).

Your task is to implement a new API endpoint that returns a task activity summary for a given IG — including tasks completed, total karma earned, unique contributors, and the top 5 contributors, with optional date range filtering.

GET /api/v1/dashboard/ig/<ig_id>/task-summary/

This endpoint will be consumed by the IG analytics section of the admin dashboard.


What to Build

Endpoint Details

Detail Value
Method GET
Auth Required
Allowed Roles ADMIN, FELLOW, ASSOCIATE
Path Param ig_id — UUID of the Interest Group
Query Params from_date and to_date (optional, format: YYYY-MM-DD)

Expected Response

{
  "hasError": false,
  "statusCode": 200,
  "message": { "general": ["Task summary fetched successfully"] },
  "response": {
    "ig_id": "abc-123",
    "ig_name": "Web Development",
    "ig_code": "WEB",
    "total_tasks_completed": 124,
    "total_karma_awarded": 3720,
    "unique_contributors": 38,
    "top_contributors": [
      {
        "full_name": "Alice Johnson",
        "muid": "alicejohnson@mulearn",
        "karma_earned": 540
      }
    ],
    "date_range": {
      "from_date": "2025-01-01",
      "to_date": "2025-03-14"
    }
  }
}

Error Cases

Situation Expected Behaviour
ig_id does not exist Failure response — "Interest Group not found"
Invalid date format Failure response — "Invalid date format. Use YYYY-MM-DD"
No activity in date range Return zeros — do not return a failure
Unauthenticated 401 (handled automatically)
Wrong role 403 (handled automatically)

Where to Work

You'll work primarily in:

  • api/dashboard/ig/dash_ig_view.py — add the new view class
  • api/dashboard/ig/urls.py — register the new URL
  • api/dashboard/ig/dash_ig_serializer.py — add a serializer if needed

Study the existing views and serializers in the ig/ and task/ modules to understand the patterns before writing code.


Deliverables

Submit everything as a single Pull Request to this repository.

Your PR description must include:

  1. A brief explanation of your implementation approach
  2. The key ORM query you used for aggregation
  3. Any assumptions you made
  4. How you tested it (Postman screenshots or steps)

Checklist

  • New view IGTaskSummaryAPI added to dash_ig_view.py
  • URL registered in urls.py (mind the ordering — Django matches top-down)
  • Serializer added to dash_ig_serializer.py (if used)
  • Date range filtering works correctly
  • Returns zeros (not failure) when no activity exists
  • Returns failure when ig_id is invalid
  • No N+1 queries — aggregation done at the database level
  • Follows existing code style and conventions

We value code quality and clarity over speed. A well-written solution that handles edge cases correctly is more impressive than a quick but broken one.


Stack: Python · Django · Django REST Framework · MySQL
Repo: https://github.com/gtech-mulearn/mulearnbackend

All the best! 🚀

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions