This commit is contained in:
ponzischeme89
2026-08-19 14:25:44 +12:00
parent 2b43b9ef12
commit 590e069366
83 changed files with 8948 additions and 1266 deletions
+22
View File
@@ -64,6 +64,14 @@ type TracearrImportState struct {
LastIncrementalAt *time.Time `json:"lastIncrementalAt,omitempty"`
LastFullAt *time.Time `json:"lastFullAt,omitempty"`
LastError string `json:"lastError,omitempty"`
// LastRebuildAt is when the household's For You rows were last rebuilt in full.
//
// It lives in this document rather than in a table of its own because it is the same
// kind of fact as the two stamps above it — where the For You pipeline has got to —
// and because the daily rebuild is now a scheduled task, which means the alternative
// was inferring "did today's rebuild happen" from run history that also records the
// ticks on which it correctly declined to run.
LastRebuildAt *time.Time `json:"lastRebuildAt,omitempty"`
}
type RecommendationProfile struct {
@@ -407,6 +415,20 @@ func (s *Store) SetTracearrImportState(ctx context.Context, state TracearrImport
return nil
}
// MarkForYouRebuild records that the household's rows have just been rebuilt.
//
// Read-modify-write rather than a whole-document put, because the importer owns the other
// two stamps in this document and an import running beside a rebuild must not lose its own.
func (s *Store) MarkForYouRebuild(ctx context.Context, at time.Time) error {
state, err := s.TracearrImportState(ctx)
if err != nil {
return err
}
stamp := at.UTC()
state.LastRebuildAt = &stamp
return s.SetTracearrImportState(ctx, state)
}
func (s *Store) ActiveRecommendationUsers(ctx context.Context) ([]Session, error) {
rows, err := s.pool.Query(ctx, `
SELECT DISTINCT ON (emby_user_id)