Replace per-kind reclassify with a single global reclassify that respects manual and Race locks
Manual assignments are the user's definitive word and Race assignments come from a hard Garmin fact (eventType.typeKey), not a retunable rule -- neither is ever touched by reclassify again, and Race can no longer be set by hand via the review queue. Adds an Activities page so this locked/unlocked status is visible per workout, since Review Queue only ever showed unresolved items.
This commit is contained in:
@@ -162,48 +162,3 @@ func (s *Server) handleUpdateWorkoutKind(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
writeJSON(w, http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// handleReclassifyKind re-runs the rule engine for every activity currently
|
||||
// assigned to (or under review for) this kind. It's a synchronous, bounded
|
||||
// operation (unlike sync), so it runs inline rather than in the background.
|
||||
func (s *Server) handleReclassifyKind(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(chi.URLParam(r, "id"), 10, 64)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusBadRequest, "invalid workout kind id")
|
||||
return
|
||||
}
|
||||
|
||||
assignments, err := s.DB.AssignmentsForKind(r.Context(), id)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
reviewQueue, err := s.DB.ReviewQueue(r.Context())
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
seen := make(map[int64]bool)
|
||||
var activityIDs []int64
|
||||
for _, a := range assignments {
|
||||
if !seen[a.ActivityID] {
|
||||
seen[a.ActivityID] = true
|
||||
activityIDs = append(activityIDs, a.ActivityID)
|
||||
}
|
||||
}
|
||||
for _, a := range reviewQueue {
|
||||
if !seen[a.ActivityID] {
|
||||
seen[a.ActivityID] = true
|
||||
activityIDs = append(activityIDs, a.ActivityID)
|
||||
}
|
||||
}
|
||||
|
||||
for _, activityID := range activityIDs {
|
||||
if err := s.Sync.ClassifyActivity(r.Context(), activityID); err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]int{"reclassified": len(activityIDs)})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user