mirror of
https://github.com/modrinth/code.git
synced 2026-08-30 11:36:05 +00:00
fix linting error with cargo fmt
This commit is contained in:
@@ -223,10 +223,10 @@ impl DBOrganization {
|
|||||||
",
|
",
|
||||||
organization_id as DBOrganizationId,
|
organization_id as DBOrganizationId,
|
||||||
)
|
)
|
||||||
.fetch(exec)
|
.fetch(exec)
|
||||||
.map_ok(|m| DBProjectId(m.id))
|
.map_ok(|m| DBProjectId(m.id))
|
||||||
.try_collect::<Vec<_>>()
|
.try_collect::<Vec<_>>()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(db_projects)
|
Ok(db_projects)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -444,7 +444,15 @@ impl From<LinkUrl> for Link {
|
|||||||
/// Scheduled - Project is scheduled to be released in the future
|
/// Scheduled - Project is scheduled to be released in the future
|
||||||
/// Private - Project is approved, but is not viewable to the public
|
/// Private - Project is approved, but is not viewable to the public
|
||||||
#[derive(
|
#[derive(
|
||||||
Serialize, Deserialize, Copy, Clone, Eq, PartialEq, Hash, Debug, utoipa::ToSchema,
|
Serialize,
|
||||||
|
Deserialize,
|
||||||
|
Copy,
|
||||||
|
Clone,
|
||||||
|
Eq,
|
||||||
|
PartialEq,
|
||||||
|
Hash,
|
||||||
|
Debug,
|
||||||
|
utoipa::ToSchema,
|
||||||
)]
|
)]
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum ProjectStatus {
|
pub enum ProjectStatus {
|
||||||
|
|||||||
@@ -2,12 +2,16 @@ use super::ApiError;
|
|||||||
use crate::auth::get_user_from_headers;
|
use crate::auth::get_user_from_headers;
|
||||||
use crate::database;
|
use crate::database;
|
||||||
use crate::database::PgPool;
|
use crate::database::PgPool;
|
||||||
use crate::database::models::{DBModerationLock, DBOrganization, DBOrganizationId, DBProjectId, DBProject};
|
|
||||||
use crate::database::models::moderation_external_item;
|
use crate::database::models::moderation_external_item;
|
||||||
|
use crate::database::models::{
|
||||||
|
DBModerationLock, DBOrganization, DBOrganizationId, DBProject, DBProjectId,
|
||||||
|
};
|
||||||
use crate::models::ids::{OrganizationId, ProjectId};
|
use crate::models::ids::{OrganizationId, ProjectId};
|
||||||
use crate::models::projects::{ProjectStatus, VersionStatus};
|
use crate::models::projects::{ProjectStatus, VersionStatus};
|
||||||
use crate::queue::moderation::{ApprovalType, IdentifiedFile, MissingMetadata};
|
use crate::queue::moderation::{ApprovalType, IdentifiedFile, MissingMetadata};
|
||||||
use crate::queue::session::AuthQueue;
|
use crate::queue::session::AuthQueue;
|
||||||
|
use crate::routes::v3::organizations::OrganizationIds;
|
||||||
|
use crate::routes::v3::users::UserIds;
|
||||||
use crate::util::error::ApiContext as _;
|
use crate::util::error::ApiContext as _;
|
||||||
use crate::util::error::Context;
|
use crate::util::error::Context;
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -18,12 +22,10 @@ use actix_web::{HttpRequest, delete, get, post, web};
|
|||||||
use ariadne::ids::{UserId, random_base62};
|
use ariadne::ids::{UserId, random_base62};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use eyre::eyre;
|
use eyre::eyre;
|
||||||
|
use futures_util::future::try_join_all;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use futures_util::future::try_join_all;
|
|
||||||
use xredis::RedisPool;
|
use xredis::RedisPool;
|
||||||
use crate::routes::v3::organizations::OrganizationIds;
|
|
||||||
use crate::routes::v3::users::UserIds;
|
|
||||||
|
|
||||||
pub mod external_license;
|
pub mod external_license;
|
||||||
mod ownership;
|
mod ownership;
|
||||||
@@ -1704,8 +1706,8 @@ pub async fn get_user_project_grouped(
|
|||||||
&session_queue,
|
&session_queue,
|
||||||
Scopes::PROJECT_READ,
|
Scopes::PROJECT_READ,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.wrap_auth_err("authenticating API request")?;
|
.wrap_auth_err("authenticating API request")?;
|
||||||
|
|
||||||
let target_user =
|
let target_user =
|
||||||
database::models::DBUser::get(&info.into_inner().0, &**pool, &redis)
|
database::models::DBUser::get(&info.into_inner().0, &**pool, &redis)
|
||||||
@@ -1737,8 +1739,10 @@ pub async fn get_users_project_grouped(
|
|||||||
pool: web::Data<PgPool>,
|
pool: web::Data<PgPool>,
|
||||||
redis: web::Data<RedisPool>,
|
redis: web::Data<RedisPool>,
|
||||||
session_queue: web::Data<AuthQueue>,
|
session_queue: web::Data<AuthQueue>,
|
||||||
) -> Result<web::Json<HashMap<UserId, HashMap<ProjectStatus, Vec<ProjectId>>>>, ApiError>
|
) -> Result<
|
||||||
{
|
web::Json<HashMap<UserId, HashMap<ProjectStatus, Vec<ProjectId>>>>,
|
||||||
|
ApiError,
|
||||||
|
> {
|
||||||
check_is_moderator_from_headers(
|
check_is_moderator_from_headers(
|
||||||
&req,
|
&req,
|
||||||
&**pool,
|
&**pool,
|
||||||
@@ -1746,8 +1750,8 @@ pub async fn get_users_project_grouped(
|
|||||||
&session_queue,
|
&session_queue,
|
||||||
Scopes::PROJECT_READ,
|
Scopes::PROJECT_READ,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.wrap_auth_err("authenticating API request")?;
|
.wrap_auth_err("authenticating API request")?;
|
||||||
|
|
||||||
let user_ids = serde_json::from_str::<Vec<String>>(&ids.ids)
|
let user_ids = serde_json::from_str::<Vec<String>>(&ids.ids)
|
||||||
.wrap_request_err("deserializing JSON data")?;
|
.wrap_request_err("deserializing JSON data")?;
|
||||||
@@ -1764,18 +1768,17 @@ pub async fn get_users_project_grouped(
|
|||||||
let pool_ref = &**pool;
|
let pool_ref = &**pool;
|
||||||
let redis_ref = &*redis;
|
let redis_ref = &*redis;
|
||||||
|
|
||||||
let grouped_projects_by_user = try_join_all(target_users.into_iter().map(
|
let grouped_projects_by_user =
|
||||||
|target_user| async move {
|
try_join_all(target_users.into_iter().map(|target_user| async move {
|
||||||
let counts = user_projects_status_grouped(
|
let counts = user_projects_status_grouped(
|
||||||
target_user.id,
|
target_user.id,
|
||||||
pool_ref,
|
pool_ref,
|
||||||
redis_ref,
|
redis_ref,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok::<_, ApiError>((UserId::from(target_user.id), counts))
|
Ok::<_, ApiError>((UserId::from(target_user.id), counts))
|
||||||
},
|
}))
|
||||||
))
|
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect::<HashMap<_, _>>();
|
.collect::<HashMap<_, _>>();
|
||||||
@@ -1807,24 +1810,21 @@ pub async fn get_organization_project_grouped(
|
|||||||
&session_queue,
|
&session_queue,
|
||||||
Scopes::PROJECT_READ,
|
Scopes::PROJECT_READ,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.wrap_auth_err("authenticating API request")?;
|
.wrap_auth_err("authenticating API request")?;
|
||||||
|
|
||||||
let target_org = database::models::DBOrganization::get(
|
let target_org = database::models::DBOrganization::get(
|
||||||
&info.into_inner().0,
|
&info.into_inner().0,
|
||||||
&**pool,
|
&**pool,
|
||||||
&redis,
|
&redis,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.wrap_internal_err("fetching organization from database")?
|
.wrap_internal_err("fetching organization from database")?
|
||||||
.wrap_not_found_err("resource not found")?;
|
.wrap_not_found_err("resource not found")?;
|
||||||
|
|
||||||
let grouped_projects = organization_projects_status_grouped(
|
let grouped_projects =
|
||||||
target_org.id,
|
organization_projects_status_grouped(target_org.id, &**pool, &redis)
|
||||||
&**pool,
|
.await?;
|
||||||
&redis,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(web::Json(grouped_projects))
|
Ok(web::Json(grouped_projects))
|
||||||
}
|
}
|
||||||
@@ -1859,8 +1859,8 @@ pub async fn get_organizations_project_grouped(
|
|||||||
&session_queue,
|
&session_queue,
|
||||||
Scopes::PROJECT_READ,
|
Scopes::PROJECT_READ,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.wrap_auth_err("authenticating API request")?;
|
.wrap_auth_err("authenticating API request")?;
|
||||||
|
|
||||||
let organization_ids = serde_json::from_str::<Vec<String>>(&ids.ids)
|
let organization_ids = serde_json::from_str::<Vec<String>>(&ids.ids)
|
||||||
.wrap_request_err("deserializing JSON data")?;
|
.wrap_request_err("deserializing JSON data")?;
|
||||||
@@ -1874,24 +1874,23 @@ pub async fn get_organizations_project_grouped(
|
|||||||
&**pool,
|
&**pool,
|
||||||
&redis,
|
&redis,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.wrap_internal_err("fetching organizations from database")?;
|
.wrap_internal_err("fetching organizations from database")?;
|
||||||
|
|
||||||
let pool_ref = &**pool;
|
let pool_ref = &**pool;
|
||||||
let redis_ref = &*redis;
|
let redis_ref = &*redis;
|
||||||
|
|
||||||
let grouped_projects_by_org = try_join_all(target_orgs.into_iter().map(
|
let grouped_projects_by_org =
|
||||||
|target_org| async move {
|
try_join_all(target_orgs.into_iter().map(|target_org| async move {
|
||||||
let counts = organization_projects_status_grouped(
|
let counts = organization_projects_status_grouped(
|
||||||
target_org.id,
|
target_org.id,
|
||||||
pool_ref,
|
pool_ref,
|
||||||
redis_ref,
|
redis_ref,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok::<_, ApiError>((OrganizationId::from(target_org.id), counts))
|
Ok::<_, ApiError>((OrganizationId::from(target_org.id), counts))
|
||||||
},
|
}))
|
||||||
))
|
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect::<HashMap<_, _>>();
|
.collect::<HashMap<_, _>>();
|
||||||
@@ -1907,8 +1906,8 @@ async fn user_projects_status_grouped<'a, E>(
|
|||||||
) -> Result<HashMap<ProjectStatus, Vec<ProjectId>>, ApiError>
|
) -> Result<HashMap<ProjectStatus, Vec<ProjectId>>, ApiError>
|
||||||
where
|
where
|
||||||
E: database::Executor<'a, Database = sqlx::Postgres>
|
E: database::Executor<'a, Database = sqlx::Postgres>
|
||||||
+ database::Acquire<'a, Database = sqlx::Postgres>
|
+ database::Acquire<'a, Database = sqlx::Postgres>
|
||||||
+ Copy,
|
+ Copy,
|
||||||
{
|
{
|
||||||
let project_ids =
|
let project_ids =
|
||||||
database::models::DBUser::get_projects(user_id, pool, redis)
|
database::models::DBUser::get_projects(user_id, pool, redis)
|
||||||
@@ -1918,7 +1917,6 @@ where
|
|||||||
grouped_projects_for(&project_ids, pool, redis).await
|
grouped_projects_for(&project_ids, pool, redis).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Groups the given Organization projects by their `ProjectStatus`.
|
/// Groups the given Organization projects by their `ProjectStatus`.
|
||||||
async fn organization_projects_status_grouped<'a, E>(
|
async fn organization_projects_status_grouped<'a, E>(
|
||||||
organization_id: DBOrganizationId,
|
organization_id: DBOrganizationId,
|
||||||
@@ -1927,8 +1925,8 @@ async fn organization_projects_status_grouped<'a, E>(
|
|||||||
) -> Result<HashMap<ProjectStatus, Vec<ProjectId>>, ApiError>
|
) -> Result<HashMap<ProjectStatus, Vec<ProjectId>>, ApiError>
|
||||||
where
|
where
|
||||||
E: database::Executor<'a, Database = sqlx::Postgres>
|
E: database::Executor<'a, Database = sqlx::Postgres>
|
||||||
+ database::Acquire<'a, Database = sqlx::Postgres>
|
+ database::Acquire<'a, Database = sqlx::Postgres>
|
||||||
+ Copy,
|
+ Copy,
|
||||||
{
|
{
|
||||||
let project_ids = DBOrganization::get_projects(organization_id, pool)
|
let project_ids = DBOrganization::get_projects(organization_id, pool)
|
||||||
.await
|
.await
|
||||||
@@ -1945,21 +1943,22 @@ async fn grouped_projects_for<'a, E>(
|
|||||||
) -> Result<HashMap<ProjectStatus, Vec<ProjectId>>, ApiError>
|
) -> Result<HashMap<ProjectStatus, Vec<ProjectId>>, ApiError>
|
||||||
where
|
where
|
||||||
E: database::Executor<'a, Database = sqlx::Postgres>
|
E: database::Executor<'a, Database = sqlx::Postgres>
|
||||||
+ database::Acquire<'a, Database = sqlx::Postgres>
|
+ database::Acquire<'a, Database = sqlx::Postgres>
|
||||||
+ Copy,
|
+ Copy,
|
||||||
{
|
{
|
||||||
if project_ids.is_empty() {
|
if project_ids.is_empty() {
|
||||||
return Ok(HashMap::new());
|
return Ok(HashMap::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
let projects =
|
let projects = DBProject::get_many_ids(project_ids, pool, redis)
|
||||||
DBProject::get_many_ids(project_ids, pool, redis)
|
.await
|
||||||
.await
|
.wrap_internal_err("fetching projects from database")?;
|
||||||
.wrap_internal_err("fetching projects from database")?;
|
|
||||||
|
|
||||||
let mut grouped_projects: HashMap<ProjectStatus, Vec<ProjectId>> = HashMap::new();
|
let mut grouped_projects: HashMap<ProjectStatus, Vec<ProjectId>> =
|
||||||
|
HashMap::new();
|
||||||
for project in &projects {
|
for project in &projects {
|
||||||
grouped_projects.entry(project.inner.status)
|
grouped_projects
|
||||||
|
.entry(project.inner.status)
|
||||||
.or_default()
|
.or_default()
|
||||||
.push(project.inner.id.into());
|
.push(project.inner.id.into());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,17 @@ use itertools::Itertools;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::ownership::get_projects_ownership;
|
use super::ownership::get_projects_ownership;
|
||||||
|
use crate::database::models::{DBOrganization, DBOrganizationId};
|
||||||
|
use crate::models::ids::OrganizationId;
|
||||||
|
use crate::routes::v3::organizations::OrganizationIds;
|
||||||
|
use crate::routes::v3::users::UserIds;
|
||||||
use crate::{
|
use crate::{
|
||||||
auth::check_is_moderator_from_headers,
|
auth::check_is_moderator_from_headers,
|
||||||
database::{
|
database::{
|
||||||
DBProject,
|
DBProject,
|
||||||
models::{
|
models::{
|
||||||
DBFileId, DBProjectId, DBThread, DBThreadId, DBUser, DBUserId, DBVersion,
|
DBFileId, DBProjectId, DBThread, DBThreadId, DBUser, DBUserId,
|
||||||
DBVersionId, DelphiReportId, DelphiReportIssueDetailsId,
|
DBVersion, DBVersionId, DelphiReportId, DelphiReportIssueDetailsId,
|
||||||
DelphiReportIssueId,
|
DelphiReportIssueId,
|
||||||
delphi_report_item::{
|
delphi_report_item::{
|
||||||
DBDelphiReport, DelphiSeverity, DelphiStatus, DelphiVerdict,
|
DBDelphiReport, DelphiSeverity, DelphiStatus, DelphiVerdict,
|
||||||
@@ -42,13 +46,9 @@ use crate::{
|
|||||||
search::SearchState,
|
search::SearchState,
|
||||||
util::error::Context,
|
util::error::Context,
|
||||||
};
|
};
|
||||||
|
use ariadne::ids::UserId;
|
||||||
use eyre::eyre;
|
use eyre::eyre;
|
||||||
use futures_util::future::try_join_all;
|
use futures_util::future::try_join_all;
|
||||||
use ariadne::ids::UserId;
|
|
||||||
use crate::database::models::{DBOrganization, DBOrganizationId};
|
|
||||||
use crate::models::ids::OrganizationId;
|
|
||||||
use crate::routes::v3::organizations::OrganizationIds;
|
|
||||||
use crate::routes::v3::users::UserIds;
|
|
||||||
|
|
||||||
pub mod global;
|
pub mod global;
|
||||||
|
|
||||||
@@ -1613,8 +1613,8 @@ pub async fn get_user_flagged_projects(
|
|||||||
&session_queue,
|
&session_queue,
|
||||||
Scopes::PROJECT_READ,
|
Scopes::PROJECT_READ,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.wrap_auth_err("authenticating API request")?;
|
.wrap_auth_err("authenticating API request")?;
|
||||||
|
|
||||||
let target_user = DBUser::get(&info.into_inner().0, &**pool, &redis)
|
let target_user = DBUser::get(&info.into_inner().0, &**pool, &redis)
|
||||||
.await
|
.await
|
||||||
@@ -1653,8 +1653,8 @@ pub async fn get_users_flagged_projects(
|
|||||||
&session_queue,
|
&session_queue,
|
||||||
Scopes::PROJECT_READ,
|
Scopes::PROJECT_READ,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.wrap_auth_err("authenticating API request")?;
|
.wrap_auth_err("authenticating API request")?;
|
||||||
|
|
||||||
let user_ids = serde_json::from_str::<Vec<String>>(&ids.ids)
|
let user_ids = serde_json::from_str::<Vec<String>>(&ids.ids)
|
||||||
.wrap_request_err("deserializing JSON data")?;
|
.wrap_request_err("deserializing JSON data")?;
|
||||||
@@ -1670,15 +1670,14 @@ pub async fn get_users_flagged_projects(
|
|||||||
let pool_ref = &**pool;
|
let pool_ref = &**pool;
|
||||||
let redis_ref = &*redis;
|
let redis_ref = &*redis;
|
||||||
|
|
||||||
let flagged_by_user = try_join_all(target_users.into_iter().map(
|
let flagged_by_user =
|
||||||
|target_user| async move {
|
try_join_all(target_users.into_iter().map(|target_user| async move {
|
||||||
let flagged =
|
let flagged =
|
||||||
user_flagged_projects(target_user.id, pool_ref, redis_ref)
|
user_flagged_projects(target_user.id, pool_ref, redis_ref)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok::<_, ApiError>((UserId::from(target_user.id), flagged))
|
Ok::<_, ApiError>((UserId::from(target_user.id), flagged))
|
||||||
},
|
}))
|
||||||
))
|
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect::<HashMap<_, _>>();
|
.collect::<HashMap<_, _>>();
|
||||||
@@ -1709,14 +1708,13 @@ pub async fn get_organization_flagged_projects(
|
|||||||
&session_queue,
|
&session_queue,
|
||||||
Scopes::PROJECT_READ,
|
Scopes::PROJECT_READ,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.wrap_auth_err("authenticating API request")?;
|
.wrap_auth_err("authenticating API request")?;
|
||||||
|
|
||||||
let target_org =
|
let target_org = DBOrganization::get(&info.into_inner().0, &**pool, &redis)
|
||||||
DBOrganization::get(&info.into_inner().0, &**pool, &redis)
|
.await
|
||||||
.await
|
.wrap_internal_err("fetching organization from database")?
|
||||||
.wrap_internal_err("fetching organization from database")?
|
.wrap_not_found_err("resource not found")?;
|
||||||
.wrap_not_found_err("resource not found")?;
|
|
||||||
|
|
||||||
let flagged =
|
let flagged =
|
||||||
organization_flagged_projects(target_org.id, &**pool, &redis).await?;
|
organization_flagged_projects(target_org.id, &**pool, &redis).await?;
|
||||||
@@ -1743,8 +1741,7 @@ pub async fn get_organizations_flagged_projects(
|
|||||||
pool: web::Data<PgPool>,
|
pool: web::Data<PgPool>,
|
||||||
redis: web::Data<RedisPool>,
|
redis: web::Data<RedisPool>,
|
||||||
session_queue: web::Data<AuthQueue>,
|
session_queue: web::Data<AuthQueue>,
|
||||||
) -> Result<web::Json<HashMap<OrganizationId, Vec<FlaggedProject>>>, ApiError>
|
) -> Result<web::Json<HashMap<OrganizationId, Vec<FlaggedProject>>>, ApiError> {
|
||||||
{
|
|
||||||
check_is_moderator_from_headers(
|
check_is_moderator_from_headers(
|
||||||
&req,
|
&req,
|
||||||
&**pool,
|
&**pool,
|
||||||
@@ -1752,8 +1749,8 @@ pub async fn get_organizations_flagged_projects(
|
|||||||
&session_queue,
|
&session_queue,
|
||||||
Scopes::PROJECT_READ,
|
Scopes::PROJECT_READ,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.wrap_auth_err("authenticating API request")?;
|
.wrap_auth_err("authenticating API request")?;
|
||||||
|
|
||||||
let organization_ids = serde_json::from_str::<Vec<String>>(&ids.ids)
|
let organization_ids = serde_json::from_str::<Vec<String>>(&ids.ids)
|
||||||
.wrap_request_err("deserializing JSON data")?;
|
.wrap_request_err("deserializing JSON data")?;
|
||||||
@@ -1770,18 +1767,17 @@ pub async fn get_organizations_flagged_projects(
|
|||||||
let pool_ref = &**pool;
|
let pool_ref = &**pool;
|
||||||
let redis_ref = &*redis;
|
let redis_ref = &*redis;
|
||||||
|
|
||||||
let flagged_by_org = try_join_all(target_orgs.into_iter().map(
|
let flagged_by_org =
|
||||||
|target_org| async move {
|
try_join_all(target_orgs.into_iter().map(|target_org| async move {
|
||||||
let flagged = organization_flagged_projects(
|
let flagged = organization_flagged_projects(
|
||||||
target_org.id,
|
target_org.id,
|
||||||
pool_ref,
|
pool_ref,
|
||||||
redis_ref,
|
redis_ref,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok::<_, ApiError>((OrganizationId::from(target_org.id), flagged))
|
Ok::<_, ApiError>((OrganizationId::from(target_org.id), flagged))
|
||||||
},
|
}))
|
||||||
))
|
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect::<HashMap<_, _>>();
|
.collect::<HashMap<_, _>>();
|
||||||
@@ -1799,8 +1795,8 @@ async fn user_flagged_projects<'a, E>(
|
|||||||
) -> Result<Vec<FlaggedProject>, ApiError>
|
) -> Result<Vec<FlaggedProject>, ApiError>
|
||||||
where
|
where
|
||||||
E: crate::database::Executor<'a, Database = sqlx::Postgres>
|
E: crate::database::Executor<'a, Database = sqlx::Postgres>
|
||||||
+ crate::database::Acquire<'a, Database = sqlx::Postgres>
|
+ crate::database::Acquire<'a, Database = sqlx::Postgres>
|
||||||
+ Copy,
|
+ Copy,
|
||||||
{
|
{
|
||||||
let project_ids = DBUser::get_projects(user_id, pool, redis)
|
let project_ids = DBUser::get_projects(user_id, pool, redis)
|
||||||
.await
|
.await
|
||||||
@@ -1820,8 +1816,8 @@ async fn organization_flagged_projects<'a, E>(
|
|||||||
) -> Result<Vec<FlaggedProject>, ApiError>
|
) -> Result<Vec<FlaggedProject>, ApiError>
|
||||||
where
|
where
|
||||||
E: crate::database::Executor<'a, Database = sqlx::Postgres>
|
E: crate::database::Executor<'a, Database = sqlx::Postgres>
|
||||||
+ crate::database::Acquire<'a, Database = sqlx::Postgres>
|
+ crate::database::Acquire<'a, Database = sqlx::Postgres>
|
||||||
+ Copy,
|
+ Copy,
|
||||||
{
|
{
|
||||||
let project_ids = DBOrganization::get_projects(organization_id, pool)
|
let project_ids = DBOrganization::get_projects(organization_id, pool)
|
||||||
.await
|
.await
|
||||||
@@ -1840,8 +1836,8 @@ async fn flagged_projects_among<'a, E>(
|
|||||||
) -> Result<Vec<FlaggedProject>, ApiError>
|
) -> Result<Vec<FlaggedProject>, ApiError>
|
||||||
where
|
where
|
||||||
E: crate::database::Executor<'a, Database = sqlx::Postgres>
|
E: crate::database::Executor<'a, Database = sqlx::Postgres>
|
||||||
+ crate::database::Acquire<'a, Database = sqlx::Postgres>
|
+ crate::database::Acquire<'a, Database = sqlx::Postgres>
|
||||||
+ Copy,
|
+ Copy,
|
||||||
{
|
{
|
||||||
if project_ids.is_empty() {
|
if project_ids.is_empty() {
|
||||||
return Ok(Vec::new());
|
return Ok(Vec::new());
|
||||||
|
|||||||
Reference in New Issue
Block a user