feat: recursive sequel graph syncing with real-time UI polling

This commit is contained in:
2026-04-08 14:05:30 +02:00
parent a861729476
commit 8b46edc15a
7 changed files with 295 additions and 177 deletions

View File

@@ -24,9 +24,12 @@ func New(db *database.Queries, client *jikan.Client) *Worker {
func (w *Worker) Start(ctx context.Context) {
log.Println("Starting relations sync worker...")
ticker := time.NewTicker(2 * time.Minute)
ticker := time.NewTicker(1 * time.Minute)
defer ticker.Stop()
// Run once immediately
w.syncRelations(ctx)
for {
select {
case <-ctx.Done():
@@ -38,7 +41,7 @@ func (w *Worker) Start(ctx context.Context) {
}
func (w *Worker) syncRelations(ctx context.Context) {
// Find up to 50 anime that need their relations synced
// Find up to 20 anime that need their relations synced
animes, err := w.db.GetAnimeNeedingRelationSync(ctx)
if err != nil {
log.Printf("worker: failed to get anime needing sync: %v", err)