This commit is contained in:
ponzischeme89
2026-08-20 07:54:03 +12:00
parent 769fe01c84
commit 434371e9cf
37 changed files with 1767 additions and 102 deletions
+24
View File
@@ -2,8 +2,11 @@ package store
import (
"context"
"errors"
"fmt"
"time"
"github.com/jackc/pgx/v5"
)
// Watch time is read out of tracearr_sessions rather than stored again.
@@ -178,3 +181,24 @@ func (s *Store) TracearrIdentities(ctx context.Context) (map[string]Recommendati
}
return out, rows.Err()
}
// TracearrIdentity is one Emby account's recorded Tracearr identity, or the zero value for
// somebody the recommendation builder has never profiled.
//
// The map above is what the console needs — it draws the whole household in one pass — and
// this is what a single request needs. Absence is not an error: a viewer with no profile
// row is matched by username alone, which is the join the two systems genuinely share.
func (s *Store) TracearrIdentity(ctx context.Context, embyUserID string) (RecommendationIdentity, error) {
var identity RecommendationIdentity
err := s.pool.QueryRow(ctx, `
SELECT tracearr_user_id, tracearr_username
FROM recommendation_user_profiles
WHERE emby_user_id = $1`, embyUserID).Scan(&identity.TracearrUserID, &identity.Username)
if errors.Is(err, pgx.ErrNoRows) {
return RecommendationIdentity{}, nil
}
if err != nil {
return RecommendationIdentity{}, fmt.Errorf("store: tracearr identity: %w", err)
}
return identity, nil
}