Fix clippy errors + lint, use turbo CI

This commit is contained in:
Jai A
2024-10-18 16:07:35 -07:00
parent 663ab83b08
commit 8dd955563e
186 changed files with 10615 additions and 6433 deletions

View File

@@ -82,7 +82,11 @@ pub struct Session {
}
impl Session {
pub async fn get<'a, E, T: Display + Hash + Eq + PartialEq + Clone + Debug>(
pub async fn get<
'a,
E,
T: Display + Hash + Eq + PartialEq + Clone + Debug,
>(
id: T,
exec: E,
redis: &RedisPool,
@@ -103,9 +107,13 @@ impl Session {
where
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
{
Session::get_many(&[crate::models::ids::SessionId::from(id)], executor, redis)
.await
.map(|x| x.into_iter().next())
Session::get_many(
&[crate::models::ids::SessionId::from(id)],
executor,
redis,
)
.await
.map(|x| x.into_iter().next())
}
pub async fn get_many_ids<'a, E>(
@@ -123,7 +131,11 @@ impl Session {
Session::get_many(&ids, exec, redis).await
}
pub async fn get_many<'a, E, T: Display + Hash + Eq + PartialEq + Clone + Debug>(
pub async fn get_many<
'a,
E,
T: Display + Hash + Eq + PartialEq + Clone + Debug,
>(
session_strings: &[T],
exec: E,
redis: &RedisPool,
@@ -226,14 +238,23 @@ impl Session {
.await?;
redis
.set_serialized_to_json(SESSIONS_USERS_NAMESPACE, user_id.0, &db_sessions, None)
.set_serialized_to_json(
SESSIONS_USERS_NAMESPACE,
user_id.0,
&db_sessions,
None,
)
.await?;
Ok(db_sessions)
}
pub async fn clear_cache(
clear_sessions: Vec<(Option<SessionId>, Option<String>, Option<UserId>)>,
clear_sessions: Vec<(
Option<SessionId>,
Option<String>,
Option<UserId>,
)>,
redis: &RedisPool,
) -> Result<(), DatabaseError> {
let mut redis = redis.connect().await?;
@@ -243,17 +264,18 @@ impl Session {
}
redis
.delete_many(
clear_sessions
.into_iter()
.flat_map(|(id, session, user_id)| {
[
(SESSIONS_NAMESPACE, id.map(|i| i.0.to_string())),
(SESSIONS_IDS_NAMESPACE, session),
(SESSIONS_USERS_NAMESPACE, user_id.map(|i| i.0.to_string())),
]
}),
)
.delete_many(clear_sessions.into_iter().flat_map(
|(id, session, user_id)| {
[
(SESSIONS_NAMESPACE, id.map(|i| i.0.to_string())),
(SESSIONS_IDS_NAMESPACE, session),
(
SESSIONS_USERS_NAMESPACE,
user_id.map(|i| i.0.to_string()),
),
]
},
))
.await?;
Ok(())
}