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