Skip to content

Implement Paginated Recent Activity Endpoint for Use#116

Merged
phertyameen merged 1 commit intoMindBlockLabs:mainfrom
RUKAYAT-CODER:feat-pagination-recent-activity
Jul 29, 2025
Merged

Implement Paginated Recent Activity Endpoint for Use#116
phertyameen merged 1 commit intoMindBlockLabs:mainfrom
RUKAYAT-CODER:feat-pagination-recent-activity

Conversation

@RUKAYAT-CODER
Copy link
Copy Markdown
Contributor

🧩 Feature: Paginated Recent Activity Endpoint for Users

📌 Overview

This PR introduces a new paginated endpoint to retrieve a user's recent activity, including puzzle completions and achievement unlocks. The logic is modularized via a dedicated provider and clean service-controller structure.

Implementation Details
✅ PuzzleActivityProvider
Created PuzzleActivityProvider to encapsulate logic for fetching and formatting recent puzzle events.

Queries PuzzleEvent repository using skip, take, and orderBy for pagination and sorting.

Formats entries into simplified, user-friendly activity descriptors.

✅ UserActivityService
Injects PuzzleActivityProvider.

Delegates logic to provider to maintain lean service architecture.

✅ UserController
Added new route handler for GET /users/:id/activity.

Validates and parses page and limit query params.

📂 Affected Files

src/user/controller/user.controller.ts
src/user/services/user-activity.service.ts (new)
src/user/providers/puzzle-activity.provider.ts (new)
src/user/interfaces/user-activity.interface.ts (new)
src/puzzle/entities/puzzle-event.entity.ts

✅ Acceptance Criteria

  • Pagination works with page and limit query params.

  • Activity is ordered by createdAt DESC.

  • Responses are clean, structured, and readable.

  • Logic is encapsulated within a dedicated provider.

  • Unit tests added for provider and service layers.

🧪 Tests Added
✅ Provider method tests (fetch + format logic).

✅ Service forwarding logic.

✅ Controller input validation and integration tests.

🚀 New Endpoint

close #101

GET /users/:id/activity?page=1&limit=5

🔍 Example Response:

[
  { "description": "Completed \"Binary Tree Maximum Depth\" puzzle", "timestamp": "2025-07-05T08:00:00Z" },
  { "description": "Unlocked \"Code Ninja\" achievement", "timestamp": "2025-07-04T16:30:00Z" }
]

Copy link
Copy Markdown
Member

@phertyameen phertyameen left a comment

Choose a reason for hiding this comment

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

Nicely done.

@phertyameen phertyameen merged commit e158998 into MindBlockLabs:main Jul 29, 2025
1 check 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.

Create paginated recent activity endpoint for users

2 participants