tercul-backend/cmd/tools/enrich/main.go
google-labs-jules[bot] 8797cec718 Refactor: In-progress refactoring to fix build.
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.
2025-09-05 15:11:30 +00:00

50 lines
1.3 KiB
Go

package main
import (
"context"
"log"
"tercul/internal/app"
"tercul/internal/jobs/linguistics"
"tercul/internal/platform/config"
)
func main() {
log.Println("Starting enrichment tool...")
// Load configuration from environment variables
config.LoadConfig()
// Initialize structured logger with appropriate log level
log.SetDefaultLevel(log.InfoLevel)
log.LogInfo("Starting Tercul enrichment tool",
log.F("environment", config.Cfg.Environment),
log.F("version", "1.0.0"))
// Build application components
appBuilder := app.NewApplicationBuilder()
if err := appBuilder.Build(); err != nil {
log.LogFatal("Failed to build application",
log.F("error", err))
}
defer appBuilder.Close()
// Get all works
works, err := appBuilder.GetApplication().WorkQueries.ListWorks(context.Background(), 1, 10000) // A bit of a hack, but should work for now
if err != nil {
log.LogFatal("Failed to get works",
log.F("error", err))
}
// Enqueue analysis for each work
for _, work := range works.Data {
err := linguistics.EnqueueAnalysisForWork(appBuilder.GetAsynqClient(), work.ID)
if err != nil {
log.LogError("Failed to enqueue analysis for work",
log.F("workID", work.ID),
log.F("error", err))
}
}
log.Println("Enrichment tool finished.")
}