From 2da56a50feac02bf8a532b84f96512d57842a8dd Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 4 Dec 2024 17:28:55 +0530 Subject: [PATCH] feat: change "re-evaluate" to "revise" --- apps/backend/src/job.rs | 7 +++---- .../routes/_dashboard.settings.miscellaneous.tsx | 6 +++--- crates/background/src/lib.rs | 2 +- crates/models/common/src/lib.rs | 2 +- crates/services/fitness/src/lib.rs | 14 +++++++------- crates/utils/database/src/lib.rs | 7 ++----- crates/utils/dependent/src/lib.rs | 8 ++++---- libs/generated/src/graphql/backend/graphql.ts | 2 +- .../src/graphql/backend/types.generated.ts | 2 +- 9 files changed, 23 insertions(+), 27 deletions(-) diff --git a/apps/backend/src/job.rs b/apps/backend/src/job.rs index 5a522e17b1..55f15a8a6e 100644 --- a/apps/backend/src/job.rs +++ b/apps/backend/src/job.rs @@ -93,10 +93,9 @@ pub async fn perform_application_job( .await .is_ok() } - ApplicationJob::ReEvaluateUserWorkouts(user_id) => exercise_service - .re_evaluate_user_workouts(user_id) - .await - .is_ok(), + ApplicationJob::ReviseUserWorkouts(user_id) => { + exercise_service.revise_user_workouts(user_id).await.is_ok() + } ApplicationJob::UpdateMetadata(metadata_id, force_update) => misc_service .update_metadata_and_notify_users(&metadata_id, force_update) .await diff --git a/apps/frontend/app/routes/_dashboard.settings.miscellaneous.tsx b/apps/frontend/app/routes/_dashboard.settings.miscellaneous.tsx index ec6b124237..4cb77ebfd8 100644 --- a/apps/frontend/app/routes/_dashboard.settings.miscellaneous.tsx +++ b/apps/frontend/app/routes/_dashboard.settings.miscellaneous.tsx @@ -151,9 +151,9 @@ export default function Page() { - Re-evaluate workouts + Revise workouts - Re-evaluate all workouts. This may be useful if exercises done + Revise all workouts. This may be useful if exercises done during a workout have changed or workouts have been edited or deleted. @@ -161,7 +161,7 @@ export default function Page() { diff --git a/crates/background/src/lib.rs b/crates/background/src/lib.rs index 735c96a6af..8c2c3dcc16 100644 --- a/crates/background/src/lib.rs +++ b/crates/background/src/lib.rs @@ -25,7 +25,7 @@ impl Message for CoreApplicationJob { #[derive(Debug, Deserialize, Serialize, Display)] pub enum ApplicationJob { ImportFromExternalSource(String, Box), - ReEvaluateUserWorkouts(String), + ReviseUserWorkouts(String), UpdateMetadata(String, bool), UpdateGithubExerciseJob(GithubExercise), UpdatePerson(String), diff --git a/crates/models/common/src/lib.rs b/crates/models/common/src/lib.rs index 7d8e2a6dc9..c23c3bfd46 100644 --- a/crates/models/common/src/lib.rs +++ b/crates/models/common/src/lib.rs @@ -137,10 +137,10 @@ meta! { #[derive(Enum, Serialize, Deserialize, Clone, Debug, Copy, PartialEq, Eq)] pub enum BackgroundJob { UpdateAllMetadata, + ReviseUserWorkouts, UpdateAllExercises, SyncIntegrationsData, PerformBackgroundTasks, - ReEvaluateUserWorkouts, RecalculateCalendarEvents, CalculateUserActivitiesAndSummary, } diff --git a/crates/services/fitness/src/lib.rs b/crates/services/fitness/src/lib.rs index fe33f3c73a..c3da9056cb 100644 --- a/crates/services/fitness/src/lib.rs +++ b/crates/services/fitness/src/lib.rs @@ -13,7 +13,7 @@ use database_models::{ user_measurement, user_to_entity, workout, workout_template, }; use database_utils::{ - deploy_job_to_re_evaluate_user_workouts, entity_in_collections, ilike_sql, item_reviews, + deploy_job_to_revise_user_workouts, entity_in_collections, ilike_sql, item_reviews, server_key_validation_guard, user_measurements_list, user_workout_details, user_workout_template_details, }; @@ -539,7 +539,7 @@ impl ExerciseService { } if new_wkt.is_changed() { new_wkt.update(&self.0.db).await?; - deploy_job_to_re_evaluate_user_workouts(&user_id, &self.0).await; + deploy_job_to_revise_user_workouts(&user_id, &self.0).await; Ok(true) } else { Ok(false) @@ -587,11 +587,11 @@ impl ExerciseService { association.update(&self.0.db).await?; } wkt.delete(&self.0.db).await?; - deploy_job_to_re_evaluate_user_workouts(&user_id, &self.0).await; + deploy_job_to_revise_user_workouts(&user_id, &self.0).await; Ok(true) } - pub async fn re_evaluate_user_workouts(&self, user_id: String) -> Result<()> { + pub async fn revise_user_workouts(&self, user_id: String) -> Result<()> { UserToEntity::delete_many() .filter(user_to_entity::Column::UserId.eq(&user_id)) .filter(user_to_entity::Column::ExerciseId.is_not_null()) @@ -608,7 +608,7 @@ impl ExerciseService { let workout_input = db_workout_to_workout_input(workout); self.create_or_update_user_workout(&user_id, workout_input) .await?; - ryot_log!(debug, "Re-evaluated workout: {}/{}", idx + 1, total); + ryot_log!(debug, "Revised workout: {}/{}", idx + 1, total); } Ok(()) } @@ -687,7 +687,7 @@ impl ExerciseService { } self.create_custom_exercise(&user_id, input.update.clone()) .await?; - deploy_job_to_re_evaluate_user_workouts(&user_id, &self.0).await; + deploy_job_to_revise_user_workouts(&user_id, &self.0).await; Ok(true) } @@ -779,7 +779,7 @@ impl ExerciseService { .ok_or_else(|| Error::new("Exercise does not exist"))?; self.change_exercise_name_in_history(merge_into, old_entity) .await?; - deploy_job_to_re_evaluate_user_workouts(&user_id, &self.0).await; + deploy_job_to_revise_user_workouts(&user_id, &self.0).await; Ok(true) } } diff --git a/crates/utils/database/src/lib.rs b/crates/utils/database/src/lib.rs index 5dc3d4b334..bbaaa4c3db 100644 --- a/crates/utils/database/src/lib.rs +++ b/crates/utils/database/src/lib.rs @@ -898,11 +898,8 @@ pub async fn deploy_job_to_calculate_user_activities_and_summary( .unwrap(); } -pub async fn deploy_job_to_re_evaluate_user_workouts( - user_id: &String, - ss: &Arc, -) { - ss.perform_application_job(ApplicationJob::ReEvaluateUserWorkouts(user_id.to_owned())) +pub async fn deploy_job_to_revise_user_workouts(user_id: &String, ss: &Arc) { + ss.perform_application_job(ApplicationJob::ReviseUserWorkouts(user_id.to_owned())) .await .unwrap(); } diff --git a/crates/utils/dependent/src/lib.rs b/crates/utils/dependent/src/lib.rs index 96b85cd8fe..8f5dddfe7e 100644 --- a/crates/utils/dependent/src/lib.rs +++ b/crates/utils/dependent/src/lib.rs @@ -21,7 +21,7 @@ use database_models::{ }; use database_utils::{ add_entity_to_collection, admin_account_guard, create_or_update_collection, - deploy_job_to_re_evaluate_user_workouts, remove_entity_from_collection, user_by_id, + deploy_job_to_revise_user_workouts, remove_entity_from_collection, user_by_id, }; use dependent_models::{ImportCompletedItem, ImportResult}; use enums::{ @@ -904,8 +904,8 @@ pub async fn deploy_background_job( )) .await?; } - BackgroundJob::ReEvaluateUserWorkouts => { - ss.perform_application_job(ApplicationJob::ReEvaluateUserWorkouts(user_id.to_owned())) + BackgroundJob::ReviseUserWorkouts => { + ss.perform_application_job(ApplicationJob::ReviseUserWorkouts(user_id.to_owned())) .await?; } }; @@ -1958,7 +1958,7 @@ pub async fn create_or_update_workout( } let data = insert.insert(&ss.db).await?; if to_update_workout.is_some() { - deploy_job_to_re_evaluate_user_workouts(user_id, ss).await; + deploy_job_to_revise_user_workouts(user_id, ss).await; } Ok(data.id) } diff --git a/libs/generated/src/graphql/backend/graphql.ts b/libs/generated/src/graphql/backend/graphql.ts index 57ccc79414..6989570780 100644 --- a/libs/generated/src/graphql/backend/graphql.ts +++ b/libs/generated/src/graphql/backend/graphql.ts @@ -104,7 +104,7 @@ export enum BackgroundJob { CalculateUserActivitiesAndSummary = 'CALCULATE_USER_ACTIVITIES_AND_SUMMARY', PerformBackgroundTasks = 'PERFORM_BACKGROUND_TASKS', RecalculateCalendarEvents = 'RECALCULATE_CALENDAR_EVENTS', - ReEvaluateUserWorkouts = 'RE_EVALUATE_USER_WORKOUTS', + ReviseUserWorkouts = 'REVISE_USER_WORKOUTS', SyncIntegrationsData = 'SYNC_INTEGRATIONS_DATA', UpdateAllExercises = 'UPDATE_ALL_EXERCISES', UpdateAllMetadata = 'UPDATE_ALL_METADATA' diff --git a/libs/generated/src/graphql/backend/types.generated.ts b/libs/generated/src/graphql/backend/types.generated.ts index e5b3c1da3c..5e9f09edf0 100644 --- a/libs/generated/src/graphql/backend/types.generated.ts +++ b/libs/generated/src/graphql/backend/types.generated.ts @@ -83,7 +83,7 @@ export enum BackgroundJob { CalculateUserActivitiesAndSummary = 'CALCULATE_USER_ACTIVITIES_AND_SUMMARY', PerformBackgroundTasks = 'PERFORM_BACKGROUND_TASKS', RecalculateCalendarEvents = 'RECALCULATE_CALENDAR_EVENTS', - ReEvaluateUserWorkouts = 'RE_EVALUATE_USER_WORKOUTS', + ReviseUserWorkouts = 'REVISE_USER_WORKOUTS', SyncIntegrationsData = 'SYNC_INTEGRATIONS_DATA', UpdateAllExercises = 'UPDATE_ALL_EXERCISES', UpdateAllMetadata = 'UPDATE_ALL_METADATA'