Skip to content

Refactor to remove Leetcode endpoint and related services #47#49

Open
AmanDeol7 wants to merge 9 commits intoDijkstra-Edu:qafrom
AmanDeol7:leetcode
Open

Refactor to remove Leetcode endpoint and related services #47#49
AmanDeol7 wants to merge 9 commits intoDijkstra-Edu:qafrom
AmanDeol7:leetcode

Conversation

@AmanDeol7
Copy link
Member

#47

Remove LeetCode Integration - Complete Feature Cleanup

📋 Description

This pull request completely removes the LeetCode profile integration feature from the Dataforge application. The refactoring includes cleanup of controllers, services, repositories, data models, DTOs, and database migrations.

🎯 Objective

Deprecate and remove the LeetCode profile feature to streamline the codebase and reduce maintenance burden.

📦 Changes Summary

Backend API

  • Removed: app/Controllers/User/leetcode_controller.py (105 lines)
    • Endpoints for syncing LeetCode data: /sync/{profile_id}/{lc_username}
    • CRUD operations for LeetCode profiles, badges, and tags
    • Get operations by profile ID, GitHub username, and LeetCode ID

Service Layer

  • Modified: app/Services/User/leetcode_service.py
    • Removed LeetCodeService class and all its methods
    • Kept utility function getAllLeetcodeData() for API fetching (read-only)
    • Removed create, update, delete, and badge/tag management operations

Data Access Layer

  • Removed: app/Repository/User/leetcode_repository.py (241 lines)
    • LeetcodeRepository - core CRUD operations
    • LeetcodeBadgeRepository - badge management
    • LeetcodeTagRepository - tag management with filtering and sorting

Data Models

  • Modified: app/Schema/SQL/Models/models.py
    • Removed Leetcode model class
    • Removed LeetcodeBadges model class
    • Removed LeetcodeTags model class
    • Removed relationship: Profile.leetcode

Enums & Constants

  • Modified: app/Schema/SQL/Enums/enums.py

    • Removed LeetcodeTagCategory enum (FUNDAMENTAL, INTERMEDIATE, ADVANCED)
  • Modified: app/Utils/error_codes.py

    • Removed 9 LeetCode-specific error codes:
      • USER_LEETCODE_DB_A01/A02/A03 (database errors)
      • USER_LEETCODE_SRV_A01/A02 (service errors)
      • USER_LEETCODE_VAL_A01 (validation error)
      • USER_LEETCODE_NF_A01/A02/A03 (not found errors)

Exception Handling

  • Modified: app/Utils/Exceptions/user_exceptions.py
    • Removed LeetcodeNotFound exception
    • Removed LeetcodeBadgeNotFound exception
    • Removed LeetcodeTagNotFound exception

Entity DTOs

  • Removed: app/Entities/leetcode_entity.py (196 lines)
    • CreateLeetcode, UpdateLeetcode, ReadLeetcode DTOs
    • CreateLeetcodeBadge, UpdateLeetcodeBadge, ReadLeetcodeBadge DTOs
    • CreateLeetcodeTag, UpdateLeetcodeTag, ReadLeetcodeTag DTOs
    • ReadLeetcodeWithRelations aggregated DTO

Application Configuration

  • Modified: app/main.py
    • Removed import: leetcode_controller
    • Removed router registration: app.include_router(leetcode_controller.router)

Database

  • Added: app/migrations/versions/a02260f2e326_drop_leetcode_models_and_tables.py
    • Drops LeetcodeTags table
    • Drops LeetcodeBadges table
    • Drops Leetcode table
    • Includes downgrade instructions for potential rollback

📝 Breaking Changes

⚠️ This is a breaking change

The following API endpoints are removed:

  • POST /Dijkstra/v1/leetcode/sync/{profile_id}/{lc_username}
  • GET /Dijkstra/v1/leetcode/id/{leetcode_id}
  • GET /Dijkstra/v1/leetcode/{github_username}
  • GET /Dijkstra/v1/leetcode/profile/{profile_id}
  • DELETE /Dijkstra/v1/leetcode/{leetcode_id}
  • All badge endpoints: /badges/*
  • All tag endpoints: /tags/*

📊 Code Impact

  • Files Deleted: 3 (controller, entity, repository)
  • Files Modified: 6 (models, enums, errors, exceptions, services, main)
  • Database Tables Dropped: 3
  • Lines Removed: ~850+

🚀 Deployment Notes

  1. Run database migration before deploying application code
  2. Ensure no external services are calling removed endpoints

Related Issue: #47
Type: Refactoring / Deprecation
Scope: User Module - LeetCode Integration

Copy link
Member

Choose a reason for hiding this comment

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

@AmanDeol7 we do not directly edit out older versions of DB migrations. You will need to generate a new version from the updated schema. Can you have a look at the instructions on the Readme for creating a new version on Alembic?

Copy link
Member

Choose a reason for hiding this comment

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

This should not be deleted. Versions (especially the base version should not be changed on your own unless its finetuning

Copy link
Member

Choose a reason for hiding this comment

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

The entire service can be deleted

Copy link
Member Author

Choose a reason for hiding this comment

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

It has getAllLeetcodeData service, which is used by statistics controller, which is later called by frontend.

Copy link
Member

@JRS296 JRS296 left a comment

Choose a reason for hiding this comment

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

Kindly make the requested changes, and let me know if you have trouble with Alembic

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.

2 participants