Files

28 lines
907 B
Go
Raw Permalink Normal View History

2026-05-22 20:26:11 -04:00
package handlers
import (
"context"
"log/slog"
)
// ProfileStaler marks a user's taste profile as stale so it gets refreshed.
type ProfileStaler interface {
MarkProfileStale(ctx context.Context, userID int, profileID string) error
}
// ProfileRefreshRequester enqueues an asynchronous profile-scoped recommendation refresh.
type ProfileRefreshRequester interface {
RequestProfileRefresh(ctx context.Context, userID int, profileID string)
}
func triggerProfileRefresh(ctx context.Context, staler ProfileStaler, requester ProfileRefreshRequester, userID int, profileID string) {
if staler != nil {
if err := staler.MarkProfileStale(ctx, userID, profileID); err != nil {
slog.WarnContext(ctx, "failed to mark profile stale", "component", "api", "user_id", userID, "profile_id", profileID, "error", err)
2026-05-22 20:26:11 -04:00
}
}
if requester != nil {
requester.RequestProfileRefresh(ctx, userID, profileID)
}
}