Fix redis pool timeout (#669)

* Fix redis pool timeout

* remove search dep project issues

* run fmt + prep
This commit is contained in:
Geometrically
2023-08-06 15:34:03 -07:00
committed by GitHub
parent 1f4ad732fd
commit e9f5bd4ac1
8 changed files with 191 additions and 219 deletions

View File

@@ -349,6 +349,7 @@ pub async fn process_payout(
_ => weekday_amount,
};
let mut clear_cache_users = Vec::new();
for (id, project) in projects_map {
if let Some(value) = &multipliers.values.get(&(id as u64)) {
let project_multiplier: Decimal =
@@ -356,8 +357,6 @@ pub async fn process_payout(
let sum_splits: Decimal = project.team_members.iter().map(|x| x.1).sum();
let mut clear_cache_users = Vec::new();
if sum_splits > Decimal::ZERO {
for (user_id, split) in project.team_members {
let payout: Decimal = payout * project_multiplier * (split / sum_splits);
@@ -387,22 +386,25 @@ pub async fn process_payout(
)
.execute(&mut *transaction)
.await?;
clear_cache_users.push(user_id);
}
}
}
crate::database::models::User::clear_caches(
&clear_cache_users
.into_iter()
.map(|x| (crate::database::models::UserId(x), None))
.collect::<Vec<_>>(),
redis,
)
.await?;
}
}
if !clear_cache_users.is_empty() {
crate::database::models::User::clear_caches(
&clear_cache_users
.into_iter()
.map(|x| (crate::database::models::UserId(x), None))
.collect::<Vec<_>>(),
redis,
)
.await?;
}
transaction.commit().await?;
Ok(())