feat: classification reads max HR from the profile instead of static config

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-17 19:13:24 +02:00
parent 078c87c413
commit c11dd152ba
2 changed files with 10 additions and 4 deletions

View File

@@ -35,8 +35,6 @@ type Config struct {
// MinConfidence is the classify.Classify threshold below which even a
// single matching kind is sent to manual review.
MinConfidence float64
// MaxHR is used only to derive avg_hr_pct_max for the rule engine.
MaxHR float64
}
func (c Config) withDefaults() Config {
@@ -296,8 +294,16 @@ func (s *Service) ClassifyActivity(ctx context.Context, activityID int64) error
if err != nil {
return fmt.Errorf("parse workout kind rules: %w", err)
}
profile, err := s.db.GetProfile(ctx)
if err != nil {
return fmt.Errorf("load profile: %w", err)
}
var maxHR float64
if profile.MaxHeartRate != nil {
maxHR = *profile.MaxHeartRate
}
ctxMetrics := buildMetricContext(activity, laps, s.cfg.MaxHR)
ctxMetrics := buildMetricContext(activity, laps, maxHR)
result := classify.Classify(ctxMetrics, rules, s.cfg.MinConfidence)
candidatesJSON, err := json.Marshal(result.Candidates)