Skip to content

Comprehensive Refactoring of Database Service, Discord Integration, and Configuration Management - #1

Open
raiyansarker wants to merge 31 commits into
mainfrom
refresh
Open

Comprehensive Refactoring of Database Service, Discord Integration, and Configuration Management#1
raiyansarker wants to merge 31 commits into
mainfrom
refresh

Conversation

@raiyansarker

Copy link
Copy Markdown
Owner

This pull request introduces a major refactor and enhancement of the TARS bot codebase. The changes focus on improving the architectural structure, migrating to a more robust database layer using Drizzle ORM, and enhancing the Discord bot integration with more granular service boundaries.

Key Changes

Database and Persistence

  • Migrated from a manual state management system to Drizzle ORM for better type safety and relationship handling.
  • Added a new database schema in src/db/schema.ts and initialized migrations.
  • Implemented a comprehensive DbService that encapsulates all database operations, including subscription management, handle tracking, and leaderboard generation.
  • Optimized the leaderboard query to use database-side sorting and limiting, improving performance for servers with many tracked users.

Discord Bot Service

  • Refactored the Discord integration into a standalone DiscordBotService.
  • Modularized the command definitions and handlers for better maintainability.
  • Implemented a more robust gateway and webhook logic using the Effect-TS framework.
  • Enhanced the /help and status reporting commands to provide more detailed information about channel-specific configurations.

Configuration and Scheduling

  • Updated the application configuration to support more granular control over polling intervals.
  • Introduced TRACKER_POLL_MINUTES to decouple rating updates from the main scheduler tick.
  • Reduced the default scheduler poll frequency to 1 minute for more responsive digest deliveries.
  • Added utility scripts for database migration and Redis cache management.

Code Quality and Testing

  • Removed the deprecated state-store.ts service.
  • Updated the test suite to align with the new service architectures, ensuring basic functionality and full suite coverage for core services.
  • Updated project documentation and environment templates to reflect the new architectural changes.

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.

1 participant