Skip to content

Commit

Permalink
feat: change "re-evaluate" to "revise"
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Dec 4, 2024
1 parent f48047e commit 2da56a5
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 27 deletions.
7 changes: 3 additions & 4 deletions apps/backend/src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,17 @@ export default function Page() {
</Stack>
<Stack>
<Box>
<Title order={4}>Re-evaluate workouts</Title>
<Title order={4}>Revise workouts</Title>
<Text>
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.
</Text>
</Box>
<Button
disabled={isEditDisabled}
{...btnProps}
value={BackgroundJob.ReEvaluateUserWorkouts}
value={BackgroundJob.ReviseUserWorkouts}
>
Re-evaluate workouts
</Button>
Expand Down
2 changes: 1 addition & 1 deletion crates/background/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Message for CoreApplicationJob {
#[derive(Debug, Deserialize, Serialize, Display)]
pub enum ApplicationJob {
ImportFromExternalSource(String, Box<DeployImportJobInput>),
ReEvaluateUserWorkouts(String),
ReviseUserWorkouts(String),
UpdateMetadata(String, bool),
UpdateGithubExerciseJob(GithubExercise),
UpdatePerson(String),
Expand Down
2 changes: 1 addition & 1 deletion crates/models/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
14 changes: 7 additions & 7 deletions crates/services/fitness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand All @@ -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(())
}
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}
}
7 changes: 2 additions & 5 deletions crates/utils/database/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SupportingService>,
) {
ss.perform_application_job(ApplicationJob::ReEvaluateUserWorkouts(user_id.to_owned()))
pub async fn deploy_job_to_revise_user_workouts(user_id: &String, ss: &Arc<SupportingService>) {
ss.perform_application_job(ApplicationJob::ReviseUserWorkouts(user_id.to_owned()))
.await
.unwrap();
}
8 changes: 4 additions & 4 deletions crates/utils/dependent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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?;
}
};
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion libs/generated/src/graphql/backend/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion libs/generated/src/graphql/backend/types.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 2da56a5

Please sign in to comment.