You've already forked AstralRinth
forked from didirus/AstralRinth
Queue Dates + Warnings, some cleanup (#549)
* Queue Dates + Warnings, some cleanup * Fix ping * Fix repeated discord messaging * Fix compile error + run fmt
This commit is contained in:
@@ -30,7 +30,7 @@ pub async fn get_projects(
|
||||
"
|
||||
SELECT id FROM mods
|
||||
WHERE status = $1
|
||||
ORDER BY updated ASC
|
||||
ORDER BY queued ASC
|
||||
LIMIT $2;
|
||||
",
|
||||
ProjectStatus::Processing.as_str(),
|
||||
|
||||
@@ -32,7 +32,7 @@ pub async fn notifications_get(
|
||||
|
||||
let notifications_data: Vec<DBNotification> =
|
||||
database::models::notification_item::Notification::get_many(
|
||||
notification_ids,
|
||||
¬ification_ids,
|
||||
&**pool,
|
||||
)
|
||||
.await?;
|
||||
@@ -127,13 +127,13 @@ pub async fn notifications_delete(
|
||||
serde_json::from_str::<Vec<NotificationId>>(&ids.ids)?
|
||||
.into_iter()
|
||||
.map(|x| x.into())
|
||||
.collect();
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let mut transaction = pool.begin().await?;
|
||||
|
||||
let notifications_data =
|
||||
database::models::notification_item::Notification::get_many(
|
||||
notification_ids,
|
||||
¬ification_ids,
|
||||
&**pool,
|
||||
)
|
||||
.await?;
|
||||
@@ -148,7 +148,7 @@ pub async fn notifications_delete(
|
||||
}
|
||||
|
||||
database::models::notification_item::Notification::remove_many(
|
||||
notifications,
|
||||
¬ifications,
|
||||
&mut transaction,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -802,6 +802,7 @@ async fn project_create_inner(
|
||||
published: now,
|
||||
updated: now,
|
||||
approved: None,
|
||||
queued: None,
|
||||
status,
|
||||
requested_status: project_builder.requested_status,
|
||||
moderator_message: None,
|
||||
@@ -844,6 +845,7 @@ async fn project_create_inner(
|
||||
response.id,
|
||||
pool,
|
||||
webhook_url,
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.ok();
|
||||
|
||||
@@ -256,12 +256,13 @@ pub async fn dependency_list(
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let dep_version_ids = dependencies
|
||||
.iter()
|
||||
.filter_map(|x| x.0)
|
||||
.collect::<Vec<database::models::VersionId>>();
|
||||
let (projects_result, versions_result) = futures::future::try_join(
|
||||
database::Project::get_many_full(&project_ids, &**pool),
|
||||
database::Version::get_many_full(
|
||||
dependencies.iter().filter_map(|x| x.0).collect(),
|
||||
&**pool,
|
||||
),
|
||||
database::Version::get_many_full(&dep_version_ids, &**pool),
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -502,18 +503,7 @@ pub async fn project_edit(
|
||||
sqlx::query!(
|
||||
"
|
||||
UPDATE mods
|
||||
SET moderation_message = NULL
|
||||
WHERE (id = $1)
|
||||
",
|
||||
id as database::models::ids::ProjectId,
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
UPDATE mods
|
||||
SET moderation_message_body = NULL
|
||||
SET moderation_message = NULL, moderation_message_body = NULL, queued = NOW()
|
||||
WHERE (id = $1)
|
||||
",
|
||||
id as database::models::ids::ProjectId,
|
||||
@@ -528,6 +518,7 @@ pub async fn project_edit(
|
||||
project_item.inner.id.into(),
|
||||
&pool,
|
||||
webhook_url,
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.ok();
|
||||
@@ -557,6 +548,7 @@ pub async fn project_edit(
|
||||
project_item.inner.id.into(),
|
||||
&pool,
|
||||
webhook_url,
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.ok();
|
||||
@@ -1234,9 +1226,12 @@ pub async fn projects_edit(
|
||||
)));
|
||||
}
|
||||
|
||||
let team_ids = projects_data
|
||||
.iter()
|
||||
.map(|x| x.inner.team_id)
|
||||
.collect::<Vec<database::models::TeamId>>();
|
||||
let team_members = database::models::TeamMember::get_from_team_full_many(
|
||||
projects_data.iter().map(|x| x.inner.team_id).collect(),
|
||||
&**pool,
|
||||
&team_ids, &**pool,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -184,7 +184,8 @@ pub async fn reports(
|
||||
.await?;
|
||||
|
||||
let query_reports = crate::database::models::report_item::Report::get_many(
|
||||
report_ids, &**pool,
|
||||
&report_ids,
|
||||
&**pool,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -121,11 +121,11 @@ pub async fn teams_get(
|
||||
.collect::<Vec<crate::database::models::ids::TeamId>>();
|
||||
|
||||
let teams_data =
|
||||
TeamMember::get_from_team_full_many(team_ids.clone(), &**pool).await?;
|
||||
TeamMember::get_from_team_full_many(&team_ids, &**pool).await?;
|
||||
|
||||
let current_user = get_user_from_headers(req.headers(), &**pool).await.ok();
|
||||
let accepted = if let Some(user) = current_user {
|
||||
TeamMember::get_from_user_id_many(team_ids, user.id.into(), &**pool)
|
||||
TeamMember::get_from_user_id_many(&team_ids, user.id.into(), &**pool)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|m| m.team_id.0)
|
||||
|
||||
@@ -45,7 +45,7 @@ pub async fn forge_updates(
|
||||
.await?;
|
||||
|
||||
let versions =
|
||||
database::models::Version::get_many_full(version_ids, &**pool).await?;
|
||||
database::models::Version::get_many_full(&version_ids, &**pool).await?;
|
||||
|
||||
let mut versions =
|
||||
filter_authorized_versions(versions, &user_option, &pool).await?;
|
||||
|
||||
@@ -44,9 +44,9 @@ pub async fn users_get(
|
||||
let user_ids = serde_json::from_str::<Vec<UserId>>(&ids.ids)?
|
||||
.into_iter()
|
||||
.map(|x| x.into())
|
||||
.collect();
|
||||
.collect::<Vec<crate::database::models::UserId>>();
|
||||
|
||||
let users_data = User::get_many(user_ids, &**pool).await?;
|
||||
let users_data = User::get_many(&user_ids, &**pool).await?;
|
||||
|
||||
let users: Vec<crate::models::users::User> =
|
||||
users_data.into_iter().map(From::from).collect();
|
||||
|
||||
@@ -31,7 +31,7 @@ pub async fn mods_list(
|
||||
let project_data = User::get_projects(id, &**pool).await?;
|
||||
|
||||
let response: Vec<_> =
|
||||
crate::database::Project::get_many(project_data, &**pool)
|
||||
crate::database::Project::get_many(&project_data, &**pool)
|
||||
.await?
|
||||
.into_iter()
|
||||
.filter(|x| can_view_private || x.status.is_approved())
|
||||
|
||||
@@ -84,7 +84,7 @@ pub async fn version_list(
|
||||
.await?;
|
||||
|
||||
let mut versions =
|
||||
database::models::Version::get_many_full(version_ids, &**pool)
|
||||
database::models::Version::get_many_full(&version_ids, &**pool)
|
||||
.await?;
|
||||
|
||||
let mut response = versions
|
||||
@@ -165,9 +165,9 @@ pub async fn versions_get(
|
||||
let version_ids = serde_json::from_str::<Vec<VersionId>>(&ids.ids)?
|
||||
.into_iter()
|
||||
.map(|x| x.into())
|
||||
.collect();
|
||||
.collect::<Vec<database::models::VersionId>>();
|
||||
let versions_data =
|
||||
database::models::Version::get_many_full(version_ids, &**pool).await?;
|
||||
database::models::Version::get_many_full(&version_ids, &**pool).await?;
|
||||
|
||||
let mut versions = Vec::new();
|
||||
|
||||
|
||||
@@ -63,14 +63,12 @@ pub async fn get_version_from_hash(
|
||||
.fetch_all(&**pool)
|
||||
.await?;
|
||||
|
||||
let versions_data = database::models::Version::get_many_full(
|
||||
result
|
||||
.iter()
|
||||
.map(|x| database::models::VersionId(x.version_id))
|
||||
.collect(),
|
||||
&**pool,
|
||||
)
|
||||
.await?;
|
||||
let version_ids = result
|
||||
.iter()
|
||||
.map(|x| database::models::VersionId(x.version_id))
|
||||
.collect::<Vec<_>>();
|
||||
let versions_data =
|
||||
database::models::Version::get_many_full(&version_ids, &**pool).await?;
|
||||
|
||||
if let Some(first) = versions_data.first() {
|
||||
if hash_query.multiple {
|
||||
@@ -357,14 +355,12 @@ pub async fn get_versions_from_hashes(
|
||||
.fetch_all(&**pool)
|
||||
.await?;
|
||||
|
||||
let versions_data = database::models::Version::get_many_full(
|
||||
result
|
||||
.iter()
|
||||
.map(|x| database::models::VersionId(x.version_id))
|
||||
.collect(),
|
||||
&**pool,
|
||||
)
|
||||
.await?;
|
||||
let version_ids = result
|
||||
.iter()
|
||||
.map(|x| database::models::VersionId(x.version_id))
|
||||
.collect::<Vec<_>>();
|
||||
let versions_data =
|
||||
database::models::Version::get_many_full(&version_ids, &**pool).await?;
|
||||
|
||||
let response: Result<HashMap<String, Version>, ApiError> = result
|
||||
.into_iter()
|
||||
@@ -518,11 +514,10 @@ pub async fn update_files(
|
||||
}
|
||||
}
|
||||
|
||||
let versions = database::models::Version::get_many_full(
|
||||
version_ids.keys().copied().collect(),
|
||||
&**pool,
|
||||
)
|
||||
.await?;
|
||||
let query_version_ids = version_ids.keys().copied().collect::<Vec<_>>();
|
||||
let versions =
|
||||
database::models::Version::get_many_full(&query_version_ids, &**pool)
|
||||
.await?;
|
||||
|
||||
let mut response = HashMap::new();
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ pub async fn version_list(
|
||||
.await?;
|
||||
|
||||
let mut versions =
|
||||
database::models::Version::get_many_full(version_ids, &**pool)
|
||||
database::models::Version::get_many_full(&version_ids, &**pool)
|
||||
.await?;
|
||||
|
||||
let mut response = versions
|
||||
@@ -179,9 +179,9 @@ pub async fn versions_get(
|
||||
serde_json::from_str::<Vec<models::ids::VersionId>>(&ids.ids)?
|
||||
.into_iter()
|
||||
.map(|x| x.into())
|
||||
.collect();
|
||||
.collect::<Vec<database::models::VersionId>>();
|
||||
let versions_data =
|
||||
database::models::Version::get_many_full(version_ids, &**pool).await?;
|
||||
database::models::Version::get_many_full(&version_ids, &**pool).await?;
|
||||
|
||||
let user_option = get_user_from_headers(req.headers(), &**pool).await.ok();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user