You've already forked AstralRinth
forked from didirus/AstralRinth
Compiler improvements (#753)
* basic redis add * toml; reverted unnecessary changes * merge issues * increased test connections --------- Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
@@ -90,6 +90,8 @@ impl Category {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let res: Option<Vec<Category>> = redis
|
||||
.get_deserialized_from_json(TAGS_NAMESPACE, "category")
|
||||
.await?;
|
||||
@@ -155,6 +157,8 @@ impl DonationPlatform {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let res: Option<Vec<DonationPlatform>> = redis
|
||||
.get_deserialized_from_json(TAGS_NAMESPACE, "donation_platform")
|
||||
.await?;
|
||||
@@ -209,6 +213,8 @@ impl ReportType {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let res: Option<Vec<String>> = redis
|
||||
.get_deserialized_from_json(TAGS_NAMESPACE, "report_type")
|
||||
.await?;
|
||||
@@ -257,6 +263,8 @@ impl ProjectType {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let res: Option<Vec<String>> = redis
|
||||
.get_deserialized_from_json(TAGS_NAMESPACE, "project_type")
|
||||
.await?;
|
||||
|
||||
@@ -157,6 +157,8 @@ impl Collection {
|
||||
{
|
||||
use futures::TryStreamExt;
|
||||
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
if collection_ids.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
@@ -166,7 +168,10 @@ impl Collection {
|
||||
|
||||
if !collection_ids.is_empty() {
|
||||
let collections = redis
|
||||
.multi_get::<String, _>(COLLECTIONS_NAMESPACE, collection_ids.iter().map(|x| x.0))
|
||||
.multi_get::<String>(
|
||||
COLLECTIONS_NAMESPACE,
|
||||
collection_ids.iter().map(|x| x.0.to_string()),
|
||||
)
|
||||
.await?;
|
||||
|
||||
for collection in collections {
|
||||
@@ -240,6 +245,8 @@ impl Collection {
|
||||
}
|
||||
|
||||
pub async fn clear_cache(id: CollectionId, redis: &RedisPool) -> Result<(), DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
redis.delete(COLLECTIONS_NAMESPACE, id.0).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@ impl Flow {
|
||||
expires: Duration,
|
||||
redis: &RedisPool,
|
||||
) -> Result<String, DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let flow = ChaCha20Rng::from_entropy()
|
||||
.sample_iter(&Alphanumeric)
|
||||
.take(32)
|
||||
@@ -71,6 +73,8 @@ impl Flow {
|
||||
}
|
||||
|
||||
pub async fn get(id: &str, redis: &RedisPool) -> Result<Option<Flow>, DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
redis.get_deserialized_from_json(FLOWS_NAMESPACE, id).await
|
||||
}
|
||||
|
||||
@@ -91,6 +95,8 @@ impl Flow {
|
||||
}
|
||||
|
||||
pub async fn remove(id: &str, redis: &RedisPool) -> Result<Option<()>, DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
redis.delete(FLOWS_NAMESPACE, id).await?;
|
||||
Ok(Some(()))
|
||||
}
|
||||
|
||||
@@ -180,6 +180,7 @@ impl Image {
|
||||
{
|
||||
use futures::TryStreamExt;
|
||||
|
||||
let mut redis = redis.connect().await?;
|
||||
if image_ids.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
@@ -191,7 +192,7 @@ impl Image {
|
||||
|
||||
if !image_ids.is_empty() {
|
||||
let images = redis
|
||||
.multi_get::<String, _>(IMAGES_NAMESPACE, image_ids)
|
||||
.multi_get::<String>(IMAGES_NAMESPACE, image_ids.iter().map(|x| x.to_string()))
|
||||
.await?;
|
||||
for image in images {
|
||||
if let Some(image) = image.and_then(|x| serde_json::from_str::<Image>(&x).ok()) {
|
||||
@@ -246,6 +247,8 @@ impl Image {
|
||||
}
|
||||
|
||||
pub async fn clear_cache(id: ImageId, redis: &RedisPool) -> Result<(), DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
redis.delete(IMAGES_NAMESPACE, id.0).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ impl Game {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let mut redis = redis.connect().await?;
|
||||
let cached_games: Option<Vec<Game>> = redis
|
||||
.get_deserialized_from_json(GAMES_LIST_NAMESPACE, "games")
|
||||
.await?;
|
||||
@@ -95,6 +96,7 @@ impl Loader {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let mut redis = redis.connect().await?;
|
||||
let cached_id: Option<i32> = redis.get_deserialized_from_json(LOADER_ID, name).await?;
|
||||
if let Some(cached_id) = cached_id {
|
||||
return Ok(Some(LoaderId(cached_id)));
|
||||
@@ -124,6 +126,7 @@ impl Loader {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let mut redis = redis.connect().await?;
|
||||
let cached_loaders: Option<Vec<Loader>> = redis
|
||||
.get_deserialized_from_json(LOADERS_LIST_NAMESPACE, "all")
|
||||
.await?;
|
||||
@@ -318,9 +321,11 @@ impl LoaderField {
|
||||
{
|
||||
type RedisLoaderFieldTuple = (LoaderId, Vec<LoaderField>);
|
||||
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let mut loader_ids = loader_ids.to_vec();
|
||||
let cached_fields: Vec<RedisLoaderFieldTuple> = redis
|
||||
.multi_get::<String, _>(LOADER_FIELDS_NAMESPACE, loader_ids.iter().map(|x| x.0))
|
||||
.multi_get::<String>(LOADER_FIELDS_NAMESPACE, loader_ids.iter().map(|x| x.0))
|
||||
.await?
|
||||
.into_iter()
|
||||
.flatten()
|
||||
@@ -399,6 +404,8 @@ impl LoaderFieldEnum {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let cached_enum = redis
|
||||
.get_deserialized_from_json(LOADER_FIELD_ENUMS_ID_NAMESPACE, enum_name)
|
||||
.await?;
|
||||
@@ -488,12 +495,13 @@ impl LoaderFieldEnumValue {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let mut redis = redis.connect().await?;
|
||||
let mut found_enums = Vec::new();
|
||||
let mut remaining_enums: Vec<LoaderFieldEnumId> = loader_field_enum_ids.to_vec();
|
||||
|
||||
if !remaining_enums.is_empty() {
|
||||
let enums = redis
|
||||
.multi_get::<String, _>(
|
||||
.multi_get::<String>(
|
||||
LOADER_FIELD_ENUM_VALUES_NAMESPACE,
|
||||
loader_field_enum_ids.iter().map(|x| x.0),
|
||||
)
|
||||
|
||||
@@ -174,8 +174,10 @@ impl Notification {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
{
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let cached_notifications: Option<Vec<Notification>> = redis
|
||||
.get_deserialized_from_json(USER_NOTIFICATIONS_NAMESPACE, user_id.0)
|
||||
.get_deserialized_from_json(USER_NOTIFICATIONS_NAMESPACE, &user_id.0.to_string())
|
||||
.await?;
|
||||
|
||||
if let Some(notifications) = cached_notifications {
|
||||
@@ -319,6 +321,8 @@ impl Notification {
|
||||
user_ids: impl IntoIterator<Item = &UserId>,
|
||||
redis: &RedisPool,
|
||||
) -> Result<(), DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
redis
|
||||
.delete_many(
|
||||
user_ids
|
||||
|
||||
@@ -103,6 +103,8 @@ impl Organization {
|
||||
{
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
if organization_strings.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
@@ -120,11 +122,12 @@ impl Organization {
|
||||
|
||||
organization_ids.append(
|
||||
&mut redis
|
||||
.multi_get::<i64, _>(
|
||||
.multi_get::<i64>(
|
||||
ORGANIZATIONS_TITLES_NAMESPACE,
|
||||
organization_strings
|
||||
.iter()
|
||||
.map(|x| x.to_string().to_lowercase()),
|
||||
.map(|x| x.to_string().to_lowercase())
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.await?
|
||||
.into_iter()
|
||||
@@ -134,7 +137,10 @@ impl Organization {
|
||||
|
||||
if !organization_ids.is_empty() {
|
||||
let organizations = redis
|
||||
.multi_get::<String, _>(ORGANIZATIONS_NAMESPACE, organization_ids)
|
||||
.multi_get::<String>(
|
||||
ORGANIZATIONS_NAMESPACE,
|
||||
organization_ids.iter().map(|x| x.to_string()),
|
||||
)
|
||||
.await?;
|
||||
|
||||
for organization in organizations {
|
||||
@@ -197,8 +203,8 @@ impl Organization {
|
||||
redis
|
||||
.set(
|
||||
ORGANIZATIONS_TITLES_NAMESPACE,
|
||||
organization.title.to_lowercase(),
|
||||
organization.id.0,
|
||||
&organization.title.to_lowercase(),
|
||||
&organization.id.0.to_string(),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
@@ -318,6 +324,8 @@ impl Organization {
|
||||
title: Option<String>,
|
||||
redis: &RedisPool,
|
||||
) -> Result<(), super::DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
redis
|
||||
.delete_many([
|
||||
(ORGANIZATIONS_NAMESPACE, Some(id.0.to_string())),
|
||||
|
||||
@@ -89,6 +89,8 @@ impl PersonalAccessToken {
|
||||
{
|
||||
use futures::TryStreamExt;
|
||||
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
if pat_strings.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
@@ -106,7 +108,7 @@ impl PersonalAccessToken {
|
||||
|
||||
pat_ids.append(
|
||||
&mut redis
|
||||
.multi_get::<i64, _>(
|
||||
.multi_get::<i64>(
|
||||
PATS_TOKENS_NAMESPACE,
|
||||
pat_strings.iter().map(|x| x.to_string()),
|
||||
)
|
||||
@@ -118,7 +120,7 @@ impl PersonalAccessToken {
|
||||
|
||||
if !pat_ids.is_empty() {
|
||||
let pats = redis
|
||||
.multi_get::<String, _>(PATS_NAMESPACE, pat_ids)
|
||||
.multi_get::<String>(PATS_NAMESPACE, pat_ids.iter().map(|x| x.to_string()))
|
||||
.await?;
|
||||
for pat in pats {
|
||||
if let Some(pat) =
|
||||
@@ -174,8 +176,8 @@ impl PersonalAccessToken {
|
||||
redis
|
||||
.set(
|
||||
PATS_TOKENS_NAMESPACE,
|
||||
pat.access_token.clone(),
|
||||
pat.id.0,
|
||||
&pat.access_token,
|
||||
&pat.id.0.to_string(),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
@@ -194,8 +196,10 @@ impl PersonalAccessToken {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let res = redis
|
||||
.get_deserialized_from_json::<Vec<i64>, _>(PATS_USERS_NAMESPACE, user_id.0)
|
||||
.get_deserialized_from_json::<Vec<i64>>(PATS_USERS_NAMESPACE, &user_id.0.to_string())
|
||||
.await?;
|
||||
|
||||
if let Some(res) = res {
|
||||
@@ -220,8 +224,8 @@ impl PersonalAccessToken {
|
||||
redis
|
||||
.set(
|
||||
PATS_USERS_NAMESPACE,
|
||||
user_id.0,
|
||||
serde_json::to_string(&db_pats)?,
|
||||
&user_id.0.to_string(),
|
||||
&serde_json::to_string(&db_pats)?,
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
@@ -232,6 +236,8 @@ impl PersonalAccessToken {
|
||||
clear_pats: Vec<(Option<PatId>, Option<String>, Option<UserId>)>,
|
||||
redis: &RedisPool,
|
||||
) -> Result<(), DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
if clear_pats.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -513,6 +513,8 @@ impl Project {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let mut found_projects = Vec::new();
|
||||
let mut remaining_strings = project_strings
|
||||
.iter()
|
||||
@@ -526,7 +528,7 @@ impl Project {
|
||||
|
||||
project_ids.append(
|
||||
&mut redis
|
||||
.multi_get::<i64, _>(
|
||||
.multi_get::<i64>(
|
||||
PROJECTS_SLUGS_NAMESPACE,
|
||||
project_strings.iter().map(|x| x.to_string().to_lowercase()),
|
||||
)
|
||||
@@ -537,7 +539,10 @@ impl Project {
|
||||
);
|
||||
if !project_ids.is_empty() {
|
||||
let projects = redis
|
||||
.multi_get::<String, _>(PROJECTS_NAMESPACE, project_ids)
|
||||
.multi_get::<String>(
|
||||
PROJECTS_NAMESPACE,
|
||||
project_ids.iter().map(|x| x.to_string()),
|
||||
)
|
||||
.await?;
|
||||
for project in projects {
|
||||
if let Some(project) =
|
||||
@@ -686,8 +691,8 @@ impl Project {
|
||||
redis
|
||||
.set(
|
||||
PROJECTS_SLUGS_NAMESPACE,
|
||||
slug.to_lowercase(),
|
||||
project.inner.id.0,
|
||||
&slug.to_lowercase(),
|
||||
&project.inner.id.0.to_string(),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
@@ -709,8 +714,13 @@ impl Project {
|
||||
{
|
||||
type Dependencies = Vec<(Option<VersionId>, Option<ProjectId>, Option<ProjectId>)>;
|
||||
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let dependencies = redis
|
||||
.get_deserialized_from_json::<Dependencies, _>(PROJECTS_DEPENDENCIES_NAMESPACE, id.0)
|
||||
.get_deserialized_from_json::<Dependencies>(
|
||||
PROJECTS_DEPENDENCIES_NAMESPACE,
|
||||
&id.0.to_string(),
|
||||
)
|
||||
.await?;
|
||||
if let Some(dependencies) = dependencies {
|
||||
return Ok(dependencies);
|
||||
@@ -755,6 +765,8 @@ impl Project {
|
||||
clear_dependencies: Option<bool>,
|
||||
redis: &RedisPool,
|
||||
) -> Result<(), DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
redis
|
||||
.delete_many([
|
||||
(PROJECTS_NAMESPACE, Some(id.0.to_string())),
|
||||
|
||||
@@ -130,6 +130,8 @@ impl Session {
|
||||
{
|
||||
use futures::TryStreamExt;
|
||||
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
if session_strings.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
@@ -147,7 +149,7 @@ impl Session {
|
||||
|
||||
session_ids.append(
|
||||
&mut redis
|
||||
.multi_get::<i64, _>(
|
||||
.multi_get::<i64>(
|
||||
SESSIONS_IDS_NAMESPACE,
|
||||
session_strings.iter().map(|x| x.to_string()),
|
||||
)
|
||||
@@ -159,7 +161,10 @@ impl Session {
|
||||
|
||||
if !session_ids.is_empty() {
|
||||
let sessions = redis
|
||||
.multi_get::<String, _>(SESSIONS_NAMESPACE, session_ids)
|
||||
.multi_get::<String>(
|
||||
SESSIONS_NAMESPACE,
|
||||
session_ids.iter().map(|x| x.to_string()),
|
||||
)
|
||||
.await?;
|
||||
for session in sessions {
|
||||
if let Some(session) =
|
||||
@@ -218,8 +223,8 @@ impl Session {
|
||||
redis
|
||||
.set(
|
||||
SESSIONS_IDS_NAMESPACE,
|
||||
session.session.clone(),
|
||||
session.id.0,
|
||||
&session.session,
|
||||
&session.id.0.to_string(),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
@@ -238,8 +243,13 @@ impl Session {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let res = redis
|
||||
.get_deserialized_from_json::<Vec<i64>, _>(SESSIONS_USERS_NAMESPACE, user_id.0)
|
||||
.get_deserialized_from_json::<Vec<i64>>(
|
||||
SESSIONS_USERS_NAMESPACE,
|
||||
&user_id.0.to_string(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
if let Some(res) = res {
|
||||
@@ -272,6 +282,8 @@ impl Session {
|
||||
clear_sessions: Vec<(Option<SessionId>, Option<String>, Option<UserId>)>,
|
||||
redis: &RedisPool,
|
||||
) -> Result<(), DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
if clear_sessions.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -197,18 +197,23 @@ impl TeamMember {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
{
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
if team_ids.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
use futures::stream::TryStreamExt;
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let mut team_ids_parsed: Vec<i64> = team_ids.iter().map(|x| x.0).collect();
|
||||
|
||||
let mut found_teams = Vec::new();
|
||||
|
||||
let teams = redis
|
||||
.multi_get::<String, _>(TEAMS_NAMESPACE, team_ids_parsed.clone())
|
||||
.multi_get::<String>(
|
||||
TEAMS_NAMESPACE,
|
||||
team_ids_parsed.iter().map(|x| x.to_string()),
|
||||
)
|
||||
.await?;
|
||||
|
||||
for team_raw in teams {
|
||||
@@ -271,6 +276,7 @@ impl TeamMember {
|
||||
}
|
||||
|
||||
pub async fn clear_cache(id: TeamId, redis: &RedisPool) -> Result<(), super::DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
redis.delete(TEAMS_NAMESPACE, id.0).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -134,6 +134,8 @@ impl User {
|
||||
{
|
||||
use futures::TryStreamExt;
|
||||
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
if users_strings.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
@@ -151,7 +153,7 @@ impl User {
|
||||
|
||||
user_ids.append(
|
||||
&mut redis
|
||||
.multi_get::<i64, _>(
|
||||
.multi_get::<i64>(
|
||||
USER_USERNAMES_NAMESPACE,
|
||||
users_strings.iter().map(|x| x.to_string().to_lowercase()),
|
||||
)
|
||||
@@ -163,7 +165,7 @@ impl User {
|
||||
|
||||
if !user_ids.is_empty() {
|
||||
let users = redis
|
||||
.multi_get::<String, _>(USERS_NAMESPACE, user_ids)
|
||||
.multi_get::<String>(USERS_NAMESPACE, user_ids.iter().map(|x| x.to_string()))
|
||||
.await?;
|
||||
for user in users {
|
||||
if let Some(user) = user.and_then(|x| serde_json::from_str::<User>(&x).ok()) {
|
||||
@@ -239,8 +241,8 @@ impl User {
|
||||
redis
|
||||
.set(
|
||||
USER_USERNAMES_NAMESPACE,
|
||||
user.username.to_lowercase(),
|
||||
user.id.0,
|
||||
&user.username.to_lowercase(),
|
||||
&user.id.0.to_string(),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
@@ -278,8 +280,13 @@ impl User {
|
||||
{
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let cached_projects = redis
|
||||
.get_deserialized_from_json::<Vec<ProjectId>, _>(USERS_PROJECTS_NAMESPACE, user_id.0)
|
||||
.get_deserialized_from_json::<Vec<ProjectId>>(
|
||||
USERS_PROJECTS_NAMESPACE,
|
||||
&user_id.0.to_string(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
if let Some(projects) = cached_projects {
|
||||
@@ -384,6 +391,8 @@ impl User {
|
||||
user_ids: &[(UserId, Option<String>)],
|
||||
redis: &RedisPool,
|
||||
) -> Result<(), DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
redis
|
||||
.delete_many(user_ids.iter().flat_map(|(id, username)| {
|
||||
[
|
||||
@@ -402,6 +411,8 @@ impl User {
|
||||
user_ids: &[UserId],
|
||||
redis: &RedisPool,
|
||||
) -> Result<(), DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
redis
|
||||
.delete_many(
|
||||
user_ids
|
||||
|
||||
@@ -492,18 +492,27 @@ impl Version {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
if version_ids.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
use futures::stream::TryStreamExt;
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let mut version_ids_parsed: Vec<i64> = version_ids.iter().map(|x| x.0).collect();
|
||||
|
||||
let mut found_versions = Vec::new();
|
||||
|
||||
let versions = redis
|
||||
.multi_get::<String, _>(VERSIONS_NAMESPACE, version_ids_parsed.clone())
|
||||
.multi_get::<String>(
|
||||
VERSIONS_NAMESPACE,
|
||||
version_ids_parsed
|
||||
.clone()
|
||||
.iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
for version in versions {
|
||||
@@ -721,18 +730,20 @@ impl Version {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
{
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
if hashes.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
let mut file_ids_parsed = hashes.to_vec();
|
||||
|
||||
let mut found_files = Vec::new();
|
||||
|
||||
let files = redis
|
||||
.multi_get::<String, _>(
|
||||
.multi_get::<String>(
|
||||
VERSION_FILES_NAMESPACE,
|
||||
file_ids_parsed
|
||||
.iter()
|
||||
@@ -829,6 +840,8 @@ impl Version {
|
||||
version: &QueryVersion,
|
||||
redis: &RedisPool,
|
||||
) -> Result<(), DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
redis
|
||||
.delete_many(
|
||||
iter::once((VERSIONS_NAMESPACE, Some(version.inner.id.0.to_string()))).chain(
|
||||
|
||||
Reference in New Issue
Block a user