mirror of
https://github.com/moghtech/komodo.git
synced 2026-04-29 21:27:26 -05:00
builder and repo summary
This commit is contained in:
@@ -54,6 +54,24 @@ impl Resolve<GetBuildersSummary, RequestUser> for State {
|
||||
GetBuildersSummary {}: GetBuildersSummary,
|
||||
user: RequestUser,
|
||||
) -> anyhow::Result<GetBuildersSummaryResponse> {
|
||||
todo!()
|
||||
let query = if user.is_admin {
|
||||
None
|
||||
} else {
|
||||
let query = doc! {
|
||||
format!("permissions.{}", user.id): { "$in": ["read", "execute", "update"] }
|
||||
};
|
||||
Some(query)
|
||||
};
|
||||
let total = self
|
||||
.db
|
||||
.builders
|
||||
.collection
|
||||
.count_documents(query, None)
|
||||
.await
|
||||
.context("failed to count all build documents")?;
|
||||
let res = GetBuildersSummaryResponse {
|
||||
total: total as u32,
|
||||
};
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,24 @@ impl Resolve<GetReposSummary, RequestUser> for State {
|
||||
GetReposSummary {}: GetReposSummary,
|
||||
user: RequestUser,
|
||||
) -> anyhow::Result<GetReposSummaryResponse> {
|
||||
todo!()
|
||||
let query = if user.is_admin {
|
||||
None
|
||||
} else {
|
||||
let query = doc! {
|
||||
format!("permissions.{}", user.id): { "$in": ["read", "execute", "update"] }
|
||||
};
|
||||
Some(query)
|
||||
};
|
||||
let total = self
|
||||
.db
|
||||
.repos
|
||||
.collection
|
||||
.count_documents(query, None)
|
||||
.await
|
||||
.context("failed to count all build documents")?;
|
||||
let res = GetReposSummaryResponse {
|
||||
total: total as u32,
|
||||
};
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user