Skip to content

Commit abcadb5

Browse files
committed
database/trustpub: Implement GitLabConfig::count_for_crate() fn
1 parent b1e6551 commit abcadb5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

crates/crates_io_database/src/models/trustpub/gitlab_config.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ pub struct GitLabConfig {
1717
pub environment: Option<String>,
1818
}
1919

20+
impl GitLabConfig {
21+
pub async fn count_for_crate(conn: &mut AsyncPgConnection, crate_id: i32) -> QueryResult<i64> {
22+
trustpub_configs_gitlab::table
23+
.filter(trustpub_configs_gitlab::crate_id.eq(crate_id))
24+
.count()
25+
.get_result(conn)
26+
.await
27+
}
28+
}
29+
2030
#[derive(Debug, Insertable)]
2131
#[diesel(table_name = trustpub_configs_gitlab, check_for_backend(diesel::pg::Pg))]
2232
pub struct NewGitLabConfig<'a> {

0 commit comments

Comments
 (0)