tercul-backend/internal/app/analytics/interfaces.go
google-labs-jules[bot] 06e6e2be85 refactor(domain): Isolate Work aggregate
This commit isolates the `Work` aggregate into its own package at `internal/domain/work`, following the first step of the refactoring plan in `refactor.md`.

- The `Work` struct, related types, and the `WorkRepository` interface have been moved to the new package.
- A circular dependency between `domain` and `work` was resolved by moving the `AnalyticsRepository` to the `app` layer.
- All references to the moved types have been updated across the entire codebase to fix compilation errors.
- Test files, including mocks and integration tests, have been updated to reflect the new structure.
2025-10-03 16:15:09 +00:00

22 lines
1.1 KiB
Go

package analytics
import (
"context"
"tercul/internal/domain"
"tercul/internal/domain/work"
"time"
)
// AnalyticsRepository defines the data access layer for analytics.
type Repository interface {
IncrementWorkCounter(ctx context.Context, workID uint, field string, value int) error
IncrementTranslationCounter(ctx context.Context, translationID uint, field string, value int) error
UpdateWorkStats(ctx context.Context, workID uint, stats work.WorkStats) error
UpdateTranslationStats(ctx context.Context, translationID uint, stats domain.TranslationStats) error
GetOrCreateWorkStats(ctx context.Context, workID uint) (*work.WorkStats, error)
GetOrCreateTranslationStats(ctx context.Context, translationID uint) (*domain.TranslationStats, error)
GetOrCreateUserEngagement(ctx context.Context, userID uint, date time.Time) (*domain.UserEngagement, error)
UpdateUserEngagement(ctx context.Context, userEngagement *domain.UserEngagement) error
UpdateTrendingWorks(ctx context.Context, timePeriod string, trending []*domain.Trending) error
GetTrendingWorks(ctx context.Context, timePeriod string, limit int) ([]*work.Work, error)
}