[tasks] Add unit handling to weigh-ins
All checks were successful
build & deploy / test (push) Successful in 1m44s
build & deploy / build-and-deploy (push) Successful in 26s

This commit is contained in:
2026-05-21 09:42:40 -04:00
parent 9d3f7f434f
commit 0d6b2c4afc
5 changed files with 120 additions and 16 deletions

View File

@ -10,28 +10,28 @@ from tasks.models import Task
logger = logging.getLogger(__name__)
FLOAT_COLUMNS = {
"WEIGHT": "weight_kg",
"WEIGHT": "weight",
"BMI": "bmi",
"BODY_FAT": "body_fat_pct",
"BONE": "bone_kg",
"MUSCLE": "muscle_kg",
"WATER": "water_pct",
"BODY_FAT": "body_fat",
"BONE": "bone",
"MUSCLE": "muscle",
"WATER": "water",
"VISCERAL_FAT": "visceral_fat",
"WAIST": "waist_cm",
"WAIST": "waist",
"CALORIES": "calories",
"BMR": "bmr",
"TDEE": "tdee",
"HEART_RATE": "heart_rate",
"CHEST": "chest_cm",
"BICEPS": "biceps_cm",
"NECK": "neck_cm",
"THIGH": "thigh_cm",
"HIPS": "hips_cm",
"CALIPER": "caliper_mm",
"CALIPER_1": "caliper_1_mm",
"CALIPER_2": "caliper_2_mm",
"CALIPER_3": "caliper_3_mm",
"LBM": "lbm_kg",
"CHEST": "chest",
"BICEPS": "biceps",
"NECK": "neck",
"THIGH": "thigh",
"HIPS": "hips",
"CALIPER": "caliper",
"CALIPER_1": "caliper_1",
"CALIPER_2": "caliper_2",
"CALIPER_3": "caliper_3",
"LBM": "lbm",
"WHR": "whr",
"WHTR": "whtr",
}
@ -83,6 +83,8 @@ def import_scale_csv(file_path, user_id):
if comment:
log_dict["comment"] = comment
log_dict["unit_type"] = user.profile.weigh_in_units
existing = Scrobble.objects.filter(
timestamp=start,
task=weigh_in,