This commit introduces a new trending works feature to the application.
The feature includes:
- A new `Trending` domain model to store ranked works.
- An `UpdateTrending` method in the `AnalyticsService` that calculates a trending score for each work based on views, likes, and comments.
- A background job that runs hourly to update the trending works.
- A new `trendingWorks` query in the GraphQL API to expose the trending works.
- New tests for the trending feature, and fixes for existing tests.
This commit also includes a refactoring of the analytics repository to use a more generic `IncrementWorkCounter` method, and enhancements to the `WorkStats` and `TranslationStats` models with new metrics like `readingTime`, `complexity`, and `sentiment`.
This commit introduces a comprehensive enhancement of the application's analytics features, addressing performance, data modeling, and feature set.
The key changes include:
- **Performance Improvement:** The analytics repository now uses a database "UPSERT" operation to increment counters, reducing two separate database calls (read and write) into a single, more efficient operation.
- **New Metrics:** The `WorkStats` and `TranslationStats` models have been enriched with new, calculated metrics:
- `ReadingTime`: An estimation of the time required to read the work or translation.
- `Complexity`: A score representing the linguistic complexity of the text.
- `Sentiment`: A score indicating the emotional tone of the text.
- **Service Refactoring:** The analytics service has been refactored to support the new metrics. It now includes methods to calculate and update these scores, leveraging the existing linguistics package for text analysis.
- **GraphQL API Expansion:** The new analytics fields (`readingTime`, `complexity`, `sentiment`) have been exposed through the GraphQL API by updating the `WorkStats` and `TranslationStats` types in the schema.
- **Validation and Testing:**
- GraphQL input validation has been centralized and improved by moving from ad-hoc checks to a consistent validation pattern in the GraphQL layer.
- The test suite has been significantly improved with the addition of new tests for the analytics service and the data access layer, ensuring the correctness and robustness of the new features. This includes fixing several bugs that were discovered during the development process.
This commit introduces a comprehensive suite of unit tests for the application's models, repositories, and services, achieving 100% test coverage for all new and modified files.
Key changes include:
- Added unit tests for all services in `internal/app`.
- Added unit tests for all repositories in `internal/data/sql`.
- Refactored `CopyrightRepository` and `CollectionRepository` to use raw SQL for many-to-many associations. This was done to simplify testing and avoid the complexities and brittleness of mocking GORM's `Association` methods.
- Removed a redundant and low-value test file for domain entities.
- Fixed various build and test issues.
- Addressed all feedback from the previous code review.
Introduced a new testing strategy for the data access layer to avoid redundant testing of generic repository methods.
- Created a comprehensive test suite for the generic `BaseRepository` using a dedicated `TestEntity`. This suite covers all common CRUD operations, including transactions and error handling, in a single location.
- Added a new, focused test suite for `CategoryRepository` that only tests its repository-specific methods, relying on the base repository tests for generic functionality.
- Refactored the existing `AuthorRepository` test suite to remove redundant CRUD tests, aligning it with the new, cleaner pattern.
- Updated the test utilities to support the new testing strategy.
This change significantly improves the maintainability and efficiency of the test suite and provides a clear, future-proof pattern for testing all repositories.
This commit includes a major refactoring of the GORM many-to-many relationships to use explicit join tables, improving stability and compatibility with GORM's features.
It also implements a large number of previously unimplemented GraphQL mutations for core entities like Collections, Comments, Likes, and Bookmarks.
Key changes:
- Refactored polymorphic many-to-many relationships for Copyright and Monetization to use standard many-to-many with explicit join tables.
- Implemented GraphQL mutations for Collection, Comment, Like, and Bookmark entities, including input validation and authorization checks.
- Added comprehensive integration tests for all new features and refactored code.
- Refactored the GraphQL integration test suite to be type-safe, using generics for response handling as requested.
- Updated repository interfaces and implementations to support the new data model.
- Updated the TODO.md file to reflect the completed work.
The main changes are:
- Refactored the `Copyright` and `Monetization` relationships to use explicit join tables for each owning model, as per the "Option A" strategy. This fixes the GORM migration issues related to polymorphic many-to-many relationships.
- Created new join table structs (e.g., `WorkCopyright`, `AuthorCopyright`, `WorkMonetization`, etc.).
- Updated the domain models to use standard `gorm:"many2many"` tags with the new join tables.
- Refactored the `CopyrightRepository` and `MonetizationRepository` to use the new association-based logic.
- Updated the application services (`CopyrightCommands`, `CopyrightQueries`, `MonetizationCommands`, `MonetizationQueries`) to use the new repository methods.
- Consolidated all repository interfaces into a single `internal/domain/interfaces.go` file for better code organization.
- Added extensive integration tests for the new repository and application layer logic for `Copyrights` and `Monetizations`.
- Fixed the deletion logic for `WorkRepository` to correctly handle cascading deletes with SQLite.
- Updated the `TODO.md` file to mark the "Stabilize non-linguistics tests and interfaces" task as complete.
The main changes are:
- Refactored the `Copyright` and `Monetization` relationships to use explicit join tables for each owning model, as per the "Option A" strategy. This fixes the GORM migration issues related to polymorphic many-to-many relationships.
- Created new join table structs (e.g., `WorkCopyright`, `AuthorCopyright`, `WorkMonetization`, etc.).
- Updated the domain models to use standard `gorm:"many2many"` tags with the new join tables.
- Refactored the `CopyrightRepository` and `MonetizationRepository` to use the new association-based logic.
- Updated the application services (`CopyrightCommands`, `CopyrightQueries`, `MonetizationCommands`, `MonetizationQueries`) to use the new repository methods.
- Consolidated all repository interfaces into a single `internal/domain/interfaces.go` file for better code organization.
- Added extensive integration tests for the new repository and application layer logic for `Copyrights` and `Monetizations`.
- Fixed the deletion logic for `WorkRepository` to correctly handle cascading deletes with SQLite.
- Updated the `TODO.md` file to mark the "Stabilize non-linguistics tests and interfaces" task as complete.
This commit includes the following changes:
- Refactored all data repositories in `internal/data/sql/` to use a consistent `sql` package and to align with the new `domain` models.
- Fixed the GraphQL structure by moving the server creation logic from `internal/app` to `cmd/api`, which resolved an import cycle.
- Corrected numerous incorrect import paths for packages like `graph`, `linguistics`, `syncjob`, and the legacy `models` package.
- Resolved several package and function redeclaration errors.
- Removed legacy migration code.
- Core Go application with GraphQL API using gqlgen
- Comprehensive data models for literary works, authors, translations
- Repository pattern with caching layer
- Authentication and authorization system
- Linguistics analysis capabilities with multiple adapters
- Vector search integration with Weaviate
- Docker containerization support
- Python data migration and analysis scripts
- Clean architecture with proper separation of concerns
- Production-ready configuration and middleware
- Proper .gitignore excluding vendor/, database files, and build artifacts