feat: add ability to get status counts for projects from users and organizations

- Also add ability to get tech review verdict counts for projects from users and organizations
This commit is contained in:
Blodhgarm
2026-08-23 18:31:13 -05:00
parent fe9ae94a5d
commit fba6ee994d
4 changed files with 688 additions and 21 deletions
@@ -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: 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<'_>,