Skip to content

refactor(otto): implement modular architecture with database support using sqlx #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

austinlparker
Copy link
Member

@austinlparker austinlparker commented May 14, 2025

Summary

  • Restructured code into specialized packages for better separation of concerns
  • Added database support with SQLite and migrations for persistent storage
  • Implemented sqlx for simplified database operations
  • Implemented oncall rotation management module
  • Added modular system for easier extension and component management
  • Fixed all linting issues across the codebase
  • Enhanced Makefile with improved tooling and workflow commands

Technical Changes

  • Created packages for database, github, logging, module, server, and telemetry
  • Implemented generic repository pattern with sqlx for database operations
  • Added SQL migrations for oncall rotation schema
  • Created oncall module with GitHub integration
  • Fixed security issues in SQL queries and input handling
  • Added comprehensive linting configuration and Makefile targets

Test Plan

  • All tests are passing with make test
  • Linting passes with make lint
  • Manual testing of oncall rotation functionality

🤖 Generated with Claude Code

This commit includes:
- Restructured code into specialized packages for better separation of concerns
- Added database support with migrations for persistent storage
- Implemented oncall rotation management module with SQLite backend
- Added module system for easy extension and component management
- Fixed all linting issues across the codebase
- Enhanced Makefile with improved tooling and workflow commands
@austinlparker austinlparker requested a review from a team as a code owner May 14, 2025 01:51
Copy link

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

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

some initial thoughts for review. code is a bit verbose, but makes sense in structure. Some suggestions on how to simplify.

Comment on lines +14 to +17
// Entity represents a database entity with an ID.
type Entity interface {
GetID() string
}

Choose a reason for hiding this comment

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

i feel like this should be in the entity.go file.

}

// Create inserts a new entity.
func (r *SQLRepository[T]) Create(ctx context.Context, entity *T) error {

Choose a reason for hiding this comment

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

IMO it would probably be easier to use something like sqlx which handles most of this mapping and selecting.

Comment on lines +24 to +28
// SlogLogger is an implementation of Logger using Go's standard log/slog package.
type SlogLogger struct {
logger *slog.Logger
}

Choose a reason for hiding this comment

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

why are we wrapping slog here and not just using directly?

}

// MockRegistry is a mock implementation of Registry for testing.
type MockRegistry struct {

Choose a reason for hiding this comment

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

i don't think we need a mock registry, we can probably use the real one.

}

// ToRow maps an entity to database column values.
func (m *OnCallRotationMapper) ToRow(entity *OnCallRotation) []interface{} {

Choose a reason for hiding this comment

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

like above, i think sqlx will handle a lot of this.

- Added jmoiron/sqlx library for simplified database operations
- Replaced custom SQL mapping with struct-based scanning
- Fixed type handling for EscalationStatus
- Updated tests to work with the new implementation
- Removed no longer needed mappers.go file
@austinlparker austinlparker changed the title Refactor Otto with Modular Architecture and Database Support Refactor Otto with Modular Architecture and Database Support using sqlx May 15, 2025
@austinlparker austinlparker changed the title Refactor Otto with Modular Architecture and Database Support using sqlx refactor(otto): implement modular architecture with database support using sqlx May 15, 2025
@jaronoff97
Copy link

@austinlparker is this ready for another review?

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