40384cc05e
Milestone #160 Opt 2 (era half). A third taste facet alongside artists + genre tags: signed weights over decade buckets ("1990s") derived from albums.release_date, rebuilt daily and scored into the taste match. - Migration 0045: taste_profile_eras table (mirrors taste_profile_tags) + taste_tuning.era_scale column (DEFAULT 0.5). - Build side (internal/taste): Config.EraScale ([0,1] damper, mirrors EnrichedTagScale), accumulate folds each play/like's decade at base*EraScale, persist atomic-replaces the era rows. - Scorer (internal/recommendation): TasteProfile gains an era term (own tanh scale + additive 0.15 share so it never weakens the existing artist/tag signal when a track is undated); candidate queries return album release_date; decadeOf mirrors the builder helper. - Tuning lab: era_scale threaded through recsettings + admin API + web card (auto-renders the new row) + Go/web tests. Mood facet deferred to #1534 (partial enrichment coverage + needs candidate-side enriched-tag loading). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
64 lines
2.1 KiB
SQL
64 lines
2.1 KiB
SQL
-- Recommendation tuning lab queries (#1250). Seeding happens via the
|
|
-- recsettings boot reconcile; shipped defaults live in Go only.
|
|
|
|
-- name: UpsertWeightProfileDefaults :exec
|
|
-- Boot reconcile: insert the shipped defaults for a profile if the row
|
|
-- doesn't exist yet. Never overwrites operator-tuned values.
|
|
INSERT INTO recommendation_weight_profiles (
|
|
profile, base_weight, like_boost, recency_weight, skip_penalty,
|
|
jitter_magnitude, context_weight, similarity_weight, taste_weight
|
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
|
ON CONFLICT (profile) DO NOTHING;
|
|
|
|
-- name: ListWeightProfiles :many
|
|
SELECT * FROM recommendation_weight_profiles ORDER BY profile;
|
|
|
|
-- name: UpdateWeightProfile :one
|
|
UPDATE recommendation_weight_profiles
|
|
SET base_weight = $2,
|
|
like_boost = $3,
|
|
recency_weight = $4,
|
|
skip_penalty = $5,
|
|
jitter_magnitude = $6,
|
|
context_weight = $7,
|
|
similarity_weight = $8,
|
|
taste_weight = $9,
|
|
updated_at = now()
|
|
WHERE profile = $1
|
|
RETURNING *;
|
|
|
|
-- name: UpsertTasteTuningDefaults :exec
|
|
INSERT INTO taste_tuning (
|
|
singleton, half_life_days, engagement_hard_skip,
|
|
engagement_neutral, engagement_full, enriched_tag_scale, era_scale
|
|
) VALUES (true, $1, $2, $3, $4, $5, $6)
|
|
ON CONFLICT (singleton) DO NOTHING;
|
|
|
|
-- name: GetTasteTuning :one
|
|
SELECT * FROM taste_tuning WHERE singleton = true;
|
|
|
|
-- name: UpdateTasteTuning :one
|
|
UPDATE taste_tuning
|
|
SET half_life_days = $1,
|
|
engagement_hard_skip = $2,
|
|
engagement_neutral = $3,
|
|
engagement_full = $4,
|
|
enriched_tag_scale = $5,
|
|
era_scale = $6,
|
|
updated_at = now()
|
|
WHERE singleton = true
|
|
RETURNING *;
|
|
|
|
-- name: InsertTuningAudit :exec
|
|
-- changes is a jsonb array of {field, old, new} objects.
|
|
INSERT INTO recommendation_tuning_audit (scope, action, changes)
|
|
VALUES ($1, $2, $3);
|
|
|
|
-- name: ListTuningAudit :many
|
|
-- Newest first; consumed by the metrics trend view (#1251) to annotate
|
|
-- knob turns on the timeline.
|
|
SELECT id, changed_at, scope, action, changes
|
|
FROM recommendation_tuning_audit
|
|
ORDER BY changed_at DESC, id DESC
|
|
LIMIT $1;
|