WT 1.1.20(4) Training plan improvements
This commit is contained in:
@@ -16,6 +16,7 @@ class ExerciseRepository {
|
||||
List<Exercise>? exerciseList;
|
||||
List<Exercise>? exerciseLogList = [];
|
||||
List<Exercise>? actualExerciseList = [];
|
||||
bool noRegistration = false;
|
||||
|
||||
double rmWendler = 0;
|
||||
double rmMcglothlin = 0;
|
||||
@@ -100,6 +101,19 @@ class ExerciseRepository {
|
||||
return savedExercise;
|
||||
}
|
||||
|
||||
void addExerciseNoRegistration() {
|
||||
final Exercise modelExercise = this.exercise!;
|
||||
modelExercise.exerciseTypeId = this.exerciseType!.exerciseTypeId;
|
||||
if (exerciseType!.unitQuantity != "1") {
|
||||
modelExercise.unitQuantity = null;
|
||||
}
|
||||
Exercise copy = modelExercise.copy();
|
||||
this.actualExerciseList!.add(copy);
|
||||
this.exerciseList = [];
|
||||
this.exerciseList!.add(copy);
|
||||
this.noRegistration = true;
|
||||
}
|
||||
|
||||
void initExercise() {
|
||||
this.createNew();
|
||||
this.exerciseType = exerciseType;
|
||||
@@ -271,7 +285,9 @@ class ExerciseRepository {
|
||||
}
|
||||
|
||||
void getSameExercise(int exerciseTypeId, String day) {
|
||||
this.actualExerciseList = [];
|
||||
if (!this.noRegistration) {
|
||||
this.actualExerciseList = [];
|
||||
}
|
||||
if (exerciseList != null) {
|
||||
int index = 0;
|
||||
for (int i = 0; i < this.exerciseList!.length; i++) {
|
||||
@@ -299,7 +315,7 @@ class ExerciseRepository {
|
||||
return average;
|
||||
}
|
||||
|
||||
double getBest1RMPercent(Exercise exercise) {
|
||||
double getBest1RM(Exercise exercise) {
|
||||
double result = 0;
|
||||
if (this.exerciseList == null || this.exerciseList!.isEmpty) {
|
||||
this.exerciseList = Cache().getExercises();
|
||||
@@ -307,9 +323,13 @@ class ExerciseRepository {
|
||||
|
||||
final int exerciseTypeId = exercise.exerciseTypeId!;
|
||||
double toCompare = this.calculate1RM(exercise);
|
||||
result = toCompare;
|
||||
|
||||
final String today = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(DateTime.now());
|
||||
List<Exercise> oldExercises = [];
|
||||
if (exerciseList == null) {
|
||||
return toCompare;
|
||||
}
|
||||
this.exerciseList!.forEach((exercise) {
|
||||
final String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
|
||||
if (exercise.exerciseTypeId == exerciseTypeId && exerciseDate.compareTo(today) < 0) {
|
||||
@@ -333,7 +353,8 @@ class ExerciseRepository {
|
||||
|
||||
double withCompare = this.calculate1RM(oldExercises.last);
|
||||
|
||||
result = toCompare >= withCompare ? (1 - toCompare / withCompare) * 100 : (1 - toCompare / withCompare) * -100;
|
||||
//result = toCompare >= withCompare ? (1 - toCompare / withCompare) * 100 : (1 - toCompare / withCompare) * -100;
|
||||
result = toCompare >= withCompare ? toCompare : withCompare;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -349,6 +370,10 @@ class ExerciseRepository {
|
||||
|
||||
final String today = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
|
||||
List<Exercise> oldExercises = [];
|
||||
|
||||
if (exerciseList == null) {
|
||||
return result;
|
||||
}
|
||||
this.exerciseList!.forEach((exercise) {
|
||||
final String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
|
||||
if (exercise.exerciseTypeId == exerciseTypeId && exerciseDate.compareTo(today) < 0) {
|
||||
@@ -363,7 +388,7 @@ class ExerciseRepository {
|
||||
return result;
|
||||
}
|
||||
|
||||
double getBestExercisePercent(Exercise exercise) {
|
||||
double getBestVolume(Exercise exercise) {
|
||||
double result = 0;
|
||||
if (this.exerciseList == null || this.exerciseList!.isEmpty) {
|
||||
this.exerciseList = Cache().getExercises();
|
||||
@@ -371,9 +396,13 @@ class ExerciseRepository {
|
||||
|
||||
final int exerciseTypeId = exercise.exerciseTypeId!;
|
||||
double toCompare = exercise.unitQuantity != null ? exercise.quantity! * exercise.unitQuantity! : exercise.quantity!;
|
||||
result = toCompare;
|
||||
|
||||
final String today = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(DateTime.now());
|
||||
List<Exercise> oldExercises = [];
|
||||
if (exerciseList == null) {
|
||||
return toCompare;
|
||||
}
|
||||
this.exerciseList!.forEach((exercise) {
|
||||
final String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
|
||||
if (exercise.exerciseTypeId == exerciseTypeId && exerciseDate.compareTo(today) < 0) {
|
||||
@@ -399,8 +428,9 @@ class ExerciseRepository {
|
||||
? oldExercises.last.quantity! * oldExercises.last.unitQuantity!
|
||||
: oldExercises.last.quantity!;
|
||||
|
||||
result = toCompare >= withCompare ? (1 - toCompare / withCompare) * 100 : (1 - toCompare / withCompare) * -100;
|
||||
print("Last Best: ${oldExercises.last} - result: $result");
|
||||
//result = toCompare >= withCompare ? (1 - toCompare / withCompare) * 100 : (1 - toCompare / withCompare) * -100;
|
||||
//print("Last Best: ${oldExercises.last} - result: $result");
|
||||
result = toCompare >= withCompare ? toCompare : withCompare;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -416,6 +446,9 @@ class ExerciseRepository {
|
||||
|
||||
final String today = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
|
||||
List<Exercise> oldExercises = [];
|
||||
if (exerciseList == null) {
|
||||
return result;
|
||||
}
|
||||
this.exerciseList!.forEach((exercise) {
|
||||
final String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
|
||||
if (exercise.exerciseTypeId == exerciseTypeId && exerciseDate.compareTo(today) < 0) {
|
||||
|
||||
@@ -172,6 +172,48 @@ class TrainingPlanRepository {
|
||||
return detail;
|
||||
}
|
||||
|
||||
int getOriginalRepeats(int trainingPlanId, CustomerTrainingPlanDetails detail) {
|
||||
TrainingPlan? plan = getTrainingPlanById(trainingPlanId);
|
||||
if (plan == null) {
|
||||
return 0;
|
||||
}
|
||||
int originalRepeats = 0;
|
||||
plan.details!.forEach((element) {
|
||||
if (element.trainingPlanDetailId == detail.trainingPlanDetailsId) {
|
||||
originalRepeats = element.repeats ?? 0;
|
||||
}
|
||||
});
|
||||
return originalRepeats;
|
||||
}
|
||||
|
||||
double getOriginalWeight(int trainingPlanId, CustomerTrainingPlanDetails detail) {
|
||||
TrainingPlan? plan = getTrainingPlanById(trainingPlanId);
|
||||
if (plan == null) {
|
||||
return 0;
|
||||
}
|
||||
double originalWeight = 0;
|
||||
plan.details!.forEach((element) {
|
||||
if (element.trainingPlanDetailId == detail.trainingPlanDetailsId) {
|
||||
originalWeight = element.weight ?? 0;
|
||||
}
|
||||
});
|
||||
return originalWeight;
|
||||
}
|
||||
|
||||
CustomerTrainingPlanDetails recalculateDetailFixRepeats(int trainingPlanId, CustomerTrainingPlanDetails detail) {
|
||||
TrainingPlan? plan = getTrainingPlanById(trainingPlanId);
|
||||
if (plan == null) {
|
||||
return detail;
|
||||
}
|
||||
int originalRepeats = getOriginalRepeats(trainingPlanId, detail);
|
||||
|
||||
detail.weight = Common.calculateWeigthByChangedQuantity(detail.weight!, detail.repeats!.toDouble(), originalRepeats.toDouble());
|
||||
detail.weight = Common.roundWeight(detail.weight!);
|
||||
print("Recalculated weight: ${detail.weight}");
|
||||
detail.repeats = originalRepeats;
|
||||
return detail;
|
||||
}
|
||||
|
||||
CustomerTrainingPlanDetails recalculateDetail(
|
||||
int trainingPlanId, CustomerTrainingPlanDetails detail, CustomerTrainingPlanDetails nextDetail) {
|
||||
CustomerTrainingPlanDetails recalculatedDetail = nextDetail;
|
||||
@@ -188,7 +230,6 @@ class TrainingPlanRepository {
|
||||
int originalRepeats = detail.repeats!;
|
||||
plan.details!.forEach((element) {
|
||||
if (element.trainingPlanDetailId == detail.trainingPlanDetailsId) {
|
||||
print("element $element");
|
||||
originalRepeats = element.repeats ?? 0;
|
||||
}
|
||||
});
|
||||
@@ -198,7 +239,7 @@ class TrainingPlanRepository {
|
||||
Common.calculateWeigthByChangedQuantity(detail.weight!, detail.repeats!.toDouble(), originalRepeats.toDouble());
|
||||
recalculatedDetail.weight = Common.roundWeight(recalculatedDetail.weight!);
|
||||
print("recalculated repeats for $originalRepeats: ${recalculatedDetail.weight}");
|
||||
recalculatedDetail.repeats = originalRepeats;
|
||||
//recalculatedDetail.repeats = originalRepeats;
|
||||
|
||||
return recalculatedDetail;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user