@@ -217,7 +217,7 @@ class DatabaseRepository @Inject constructor(
217217 private val DERIVED_VALUES_TAG = " DerivedValues" // Specific tag for this complex logic
218218
219219 /* *
220- * Recalculates all derived measurement values (like BMI, LBM, etc.) for a given measurement.
220+ * Recalculates all derived measurement values (like BMI, etc.) for a given measurement.
221221 * This method fetches the necessary base values and user data, then processes each calculation.
222222 *
223223 * @param measurementId The ID of the measurement for which to recalculate derived values.
@@ -252,7 +252,7 @@ class DatabaseRepository @Inject constructor(
252252 val valueObject = currentMeasurementValues.find { it.typeId == measurementTypeObject.id }
253253 val value = valueObject?.floatValue
254254 val unit = measurementTypeObject.unit // The unit is defined in the MeasurementType object
255- LogManager .v(DERIVED_VALUES_TAG , " findValueAndUnit for $key (typeId: ${measurementTypeObject.id} , unit: $unit ): ${value ? : " not found" } " )
255+ // LogManager.v(DERIVED_VALUES_TAG, "findValueAndUnit for $key (typeId: ${measurementTypeObject.id}, unit: $unit): ${value ?: "not found"}")
256256 Pair (value, unit)
257257 }
258258 }
@@ -386,7 +386,6 @@ class DatabaseRepository @Inject constructor(
386386 // Pass the converted values (e.g., weightKg, waistCm) to the processing functions
387387
388388 processBmiCalculation(weightKg, userHeightCm).also { saveOrUpdateDerivedValue(it, MeasurementTypeKey .BMI ) }
389- processLbmCalculation(weightKg, bodyFatPercentage).also { saveOrUpdateDerivedValue(it, MeasurementTypeKey .LBM ) }
390389 processWhrCalculation(waistCm, hipsCm).also { saveOrUpdateDerivedValue(it, MeasurementTypeKey .WHR ) }
391390 processWhtrCalculation(waistCm, userHeightCm).also { saveOrUpdateDerivedValue(it, MeasurementTypeKey .WHTR ) }
392391 processBmrCalculation(
@@ -424,23 +423,6 @@ class DatabaseRepository @Inject constructor(
424423 }
425424 }
426425
427- private fun processLbmCalculation (weightKg : Float? , bodyFatPercentage : Float? ): Float? {
428- LogManager .v(CALC_PROCESS_TAG , " Processing LBM: weight=$weightKg kg, bodyFat=$bodyFatPercentage %" )
429- return if (weightKg != null && weightKg > 0f && bodyFatPercentage != null && bodyFatPercentage in 0f .. 100f ) {
430- val fatMass = weightKg * (bodyFatPercentage / 100f )
431- weightKg - fatMass
432- } else {
433- if (bodyFatPercentage != null && bodyFatPercentage !in 0f .. 100f ) {
434- LogManager .w(CALC_PROCESS_TAG , " Invalid body fat percentage for LBM calculation: $bodyFatPercentage %. Must be between 0 and 100." )
435- } else if (weightKg == null || weightKg <= 0f ) {
436- LogManager .d(CALC_PROCESS_TAG , " LBM calculation skipped: Missing or invalid weight." )
437- } else {
438- LogManager .d(CALC_PROCESS_TAG , " LBM calculation skipped: Missing body fat percentage." )
439- }
440- null
441- }
442- }
443-
444426 private fun processWhrCalculation (waistCm : Float? , hipsCm : Float? ): Float? {
445427 LogManager .v(CALC_PROCESS_TAG , " Processing WHR: waist=$waistCm cm, hips=$hipsCm cm" )
446428 return if (waistCm != null && waistCm > 0f && hipsCm != null && hipsCm > 0f ) {
0 commit comments