feat: add relaxed arm circumference measurement and update related features
- Introduced `c_arm_relaxed` to the CircumferenceEntry model for tracking relaxed arm measurements. - Updated database schema to include `c_arm_relaxed` in the circumference_log table. - Implemented calculation for 28-day relaxed arm circumference change with `calculate_arm_relaxed_28d_delta`. - Enhanced placeholder resolver and registration to support new relaxed arm measurement. - Updated frontend components to accommodate the new measurement, including forms and CSV exports. - Improved documentation and guide data to reflect the addition of relaxed arm measurements.
This commit is contained in:
1 parent
0035d08149
commit
df0165bee3
16 files changed
+122
-33
No files matched your search
@@ -67,10 +67,10 @@ def upsert_circ(e: CircumferenceEntry, x_profile_id: Optional[str]=Header(defaul
|
||||
# INSERT new entry
|
||||
eid = str(uuid.uuid4())
|
||||
cur.execute("""INSERT INTO circumference_log
|
||||
(id,profile_id,date,c_neck,c_chest,c_waist,c_belly,c_hip,c_thigh,c_calf,c_arm,notes,photo_id,created)
|
||||
VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,CURRENT_TIMESTAMP)""",
|
||||
(id,profile_id,date,c_neck,c_chest,c_waist,c_belly,c_hip,c_thigh,c_calf,c_arm,c_arm_relaxed,notes,photo_id,created)
|
||||
VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,CURRENT_TIMESTAMP)""",
|
||||
(eid,pid,d['date'],d['c_neck'],d['c_chest'],d['c_waist'],d['c_belly'],
|
||||
d['c_hip'],d['c_thigh'],d['c_calf'],d['c_arm'],d['notes'],d['photo_id']))
|
||||
d['c_hip'],d['c_thigh'],d['c_calf'],d['c_arm'],d.get('c_arm_relaxed'),d['notes'],d['photo_id']))
|
||||
|
||||
# Phase 2: Increment usage counter (only for new entries)
|
||||
increment_feature_usage(pid, 'circumference_entries')
|
||||
|
||||
@@ -312,14 +312,38 @@ Datumsformat: YYYY-MM-DD
|
||||
cur.execute("SELECT id, date, weight, note, source, created FROM weight_log WHERE profile_id=%s ORDER BY date", (pid,))
|
||||
write_csv(zf, "weight.csv", [r2d(r) for r in cur.fetchall()], ['id','date','weight','note','source','created'])
|
||||
|
||||
cur.execute("SELECT id, date, c_waist, c_hip, c_chest, c_neck, c_arm, c_thigh, c_calf, notes, created FROM circumference_log WHERE profile_id=%s ORDER BY date", (pid,))
|
||||
cur.execute(
|
||||
"SELECT id, date, c_waist, c_hip, c_chest, c_neck, c_arm, c_arm_relaxed, c_thigh, c_calf, notes, created FROM circumference_log WHERE profile_id=%s ORDER BY date",
|
||||
(pid,),
|
||||
)
|
||||
rows = [r2d(r) for r in cur.fetchall()]
|
||||
for r in rows:
|
||||
r['waist'] = r.pop('c_waist', None); r['hip'] = r.pop('c_hip', None)
|
||||
r['chest'] = r.pop('c_chest', None); r['neck'] = r.pop('c_neck', None)
|
||||
r['upper_arm'] = r.pop('c_arm', None); r['thigh'] = r.pop('c_thigh', None)
|
||||
r['upper_arm_contracted'] = r.pop('c_arm', None)
|
||||
r['upper_arm_relaxed'] = r.pop('c_arm_relaxed', None)
|
||||
r['thigh'] = r.pop('c_thigh', None)
|
||||
r['calf'] = r.pop('c_calf', None); r['forearm'] = None; r['note'] = r.pop('notes', None)
|
||||
write_csv(zf, "circumferences.csv", rows, ['id','date','waist','hip','chest','neck','upper_arm','thigh','calf','forearm','note','created'])
|
||||
write_csv(
|
||||
zf,
|
||||
"circumferences.csv",
|
||||
rows,
|
||||
[
|
||||
'id',
|
||||
'date',
|
||||
'waist',
|
||||
'hip',
|
||||
'chest',
|
||||
'neck',
|
||||
'upper_arm_contracted',
|
||||
'upper_arm_relaxed',
|
||||
'thigh',
|
||||
'calf',
|
||||
'forearm',
|
||||
'note',
|
||||
'created',
|
||||
],
|
||||
)
|
||||
|
||||
cur.execute("SELECT id, date, sf_chest, sf_abdomen, sf_thigh, sf_triceps, sf_subscap, sf_suprailiac, sf_axilla, sf_method, body_fat_pct, notes, created FROM caliper_log WHERE profile_id=%s ORDER BY date", (pid,))
|
||||
rows = [r2d(r) for r in cur.fetchall()]
|
||||
|
||||
@@ -112,12 +112,17 @@ async def import_zip(
|
||||
csv_data = zf.read('data/circumferences.csv').decode('utf-8-sig')
|
||||
reader = csv.DictReader(io.StringIO(csv_data), delimiter=';')
|
||||
for row in reader:
|
||||
_ua_contr = (
|
||||
row.get('upper_arm_contracted')
|
||||
or row.get('upper_arm')
|
||||
)
|
||||
_ua_rel = row.get('upper_arm_relaxed')
|
||||
cur.execute("""
|
||||
INSERT INTO circumference_log (
|
||||
profile_id, date, c_waist, c_hip, c_chest, c_neck,
|
||||
c_arm, c_thigh, c_calf, notes, created
|
||||
c_arm, c_arm_relaxed, c_thigh, c_calf, notes, created
|
||||
)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
ON CONFLICT (profile_id, date) DO NOTHING
|
||||
""", (
|
||||
pid,
|
||||
@@ -126,7 +131,8 @@ async def import_zip(
|
||||
float(row['hip']) if row.get('hip') else None,
|
||||
float(row['chest']) if row.get('chest') else None,
|
||||
float(row['neck']) if row.get('neck') else None,
|
||||
float(row['upper_arm']) if row.get('upper_arm') else None,
|
||||
float(_ua_contr) if _ua_contr not in (None, '') else None,
|
||||
float(_ua_rel) if _ua_rel not in (None, '') else None,
|
||||
float(row['thigh']) if row.get('thigh') else None,
|
||||
float(row['calf']) if row.get('calf') else None,
|
||||
row.get('note', ''),
|
||||
|
||||
Reference in new issue
Block a user