Skip to content
25 changes: 25 additions & 0 deletions apps/labrinth/src/database/models/organization_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,31 @@ impl DBOrganization {
}
}

pub async fn get_projects<'a, E>(
organization_id: DBOrganizationId,
exec: E,
) -> Result<Vec<DBProjectId>, super::DatabaseError>
where
E: crate::database::Executor<'a, Database = sqlx::Postgres>,
{
use futures::TryStreamExt;

let db_projects = sqlx::query!(
"
SELECT m.id FROM organizations o
INNER JOIN mods m ON m.organization_id = o.id
WHERE o.id = $1
",
organization_id as DBOrganizationId,
)
.fetch(exec)
.map_ok(|m| DBProjectId(m.id))
.try_collect::<Vec<_>>()
.await?;

Ok(db_projects)
}

pub async fn remove(
id: DBOrganizationId,
transaction: &mut PgTransaction<'_>,
Expand Down
10 changes: 9 additions & 1 deletion apps/labrinth/src/models/v3/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,15 @@ impl From<LinkUrl> for Link {
/// Scheduled - Project is scheduled to be released in the future
/// Private - Project is approved, but is not viewable to the public
#[derive(
Serialize, Deserialize, Copy, Clone, Eq, PartialEq, Debug, utoipa::ToSchema,
Serialize,
Deserialize,
Copy,
Clone,
Eq,
PartialEq,
Hash,
Debug,
utoipa::ToSchema,
)]
#[serde(rename_all = "lowercase")]
pub enum ProjectStatus {
Expand Down
Loading
Loading