feat: per-user workout numbering (#7)

Display workouts as "#N" based on each user's own ordered list of
non-deleted workouts (rank by timestamp ascending). Global auto-
increment id stays the primary key, used only internally and in
exports. User-visible surfaces now all use the per-user number:
- /history listing
- /delete now accepts the per-user number
- Save confirmations (bot text and Mini App toast)

Deleting a workout renumbers the later ones downward, as expected
for a pure display transform.

New db helpers: get_user_workout_number, resolve_user_number, and
get_workouts now includes user_number per row via SQLite window
function.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Danny 2026-04-18 22:32:24 +02:00
parent 8e22cdb29d
commit bc1d44b556
6 changed files with 129 additions and 19 deletions

View file

@ -580,7 +580,7 @@ btnSaveWorkout.addEventListener("click", async () => {
showToast("Workout updated!");
} else {
data = await api("POST", "/workouts", { superset_groups, note });
showToast("Workout #" + data.workout_id + " saved!");
showToast("Workout #" + (data.user_number ?? data.workout_id) + " saved!");
}
workout = [];
currentExercise = null;
@ -610,7 +610,7 @@ document.getElementById("btn-save-raw").addEventListener("click", async () => {
const data = await api("POST", "/workouts", { raw_text: raw });
document.getElementById("inp-raw").value = "";
clearDraft();
showToast("Workout #" + data.workout_id + " saved!");
showToast("Workout #" + (data.user_number ?? data.workout_id) + " saved!");
tg.HapticFeedback.notificationOccurred("success");
} catch (e) {
showToast(e.message);