Accept integral preparation weight targets
This commit is contained in:
parent
ed3301217f
commit
189307b548
2 changed files with 15 additions and 6 deletions
|
|
@ -792,10 +792,16 @@ static TrainlogStatus insert_preparation_entry(TrainlogDatabase *database,
|
|||
value = yyjson_obj_get(entry, "target_weight_kg");
|
||||
if (value == NULL || yyjson_is_null(value)) {
|
||||
(void)sqlite3_bind_null(statement, 11);
|
||||
} else if (!yyjson_is_num(value) || !isfinite(yyjson_get_real(value)) ||
|
||||
yyjson_get_real(value) <= 0.0 || yyjson_get_real(value) > 2000.0 ||
|
||||
sqlite3_bind_double(statement, 11, yyjson_get_real(value)) != SQLITE_OK) {
|
||||
goto invalid;
|
||||
} else {
|
||||
double target_weight;
|
||||
if (!yyjson_is_num(value)) {
|
||||
goto invalid;
|
||||
}
|
||||
target_weight = yyjson_get_num(value);
|
||||
if (!isfinite(target_weight) || target_weight <= 0.0 || target_weight > 2000.0 ||
|
||||
sqlite3_bind_double(statement, 11, target_weight) != SQLITE_OK) {
|
||||
goto invalid;
|
||||
}
|
||||
}
|
||||
if (!bind_nullable_text(statement, 12, yyjson_obj_get(entry, "notes"))) {
|
||||
goto invalid;
|
||||
|
|
|
|||
|
|
@ -46,8 +46,11 @@ static bool creation_replay_revision_and_pagination(void) {
|
|||
"\"occurrences\":[]}";
|
||||
static const char DERIVED_BODY[] =
|
||||
"{\"title\":\"Derived\",\"session_type\":\"training\","
|
||||
"\"planned_for\":null,\"notes\":null,\"editing_state\":\"draft\","
|
||||
"\"occurrences\":[],\"source_proposal_id\":"
|
||||
"\"planned_for\":\"2026-09-17\",\"notes\":null,\"editing_state\":\"ready\","
|
||||
"\"occurrences\":[{\"exercise_id\":\"ex_aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa\","
|
||||
"\"equipment_id\":null,\"load_mode\":\"external\",\"rest_seconds\":90,"
|
||||
"\"target_sets\":4,\"target_reps\":10,\"target_duration_seconds\":null,"
|
||||
"\"target_weight_kg\":39,\"notes\":null}],\"source_proposal_id\":"
|
||||
"\"aid_11111111-1111-4111-8111-111111111111\","
|
||||
"\"source_payload_sha256\":"
|
||||
"\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}";
|
||||
|
|
|
|||
Loading…
Reference in a new issue