Skip to content

Commit 0486ba4

Browse files
committed
Make owner mandatory if repo exists in get_active and get_merged
1 parent f5086d9 commit 0486ba4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

fplus-database/src/database/applications.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,13 @@ pub async fn get_merged_applications(owner: Option<String>, repo: Option<String>
7272
let conn = get_database_connection().await?;
7373
let mut query = Application::find()
7474
.filter(Column::PrNumber.eq(0));
75-
if let Some(owner) = owner {
75+
if let Some(owner) = owner.clone() {
7676
query = query.filter(Column::Owner.contains(owner));
7777
}
7878
if let Some(repo) = repo {
79+
if owner.is_none() {
80+
return Err(DbErr::Custom(format!("Owner is required to get merged applications").into()));
81+
}
7982
query = query.filter(Column::Repo.contains(repo));
8083
}
8184
query
@@ -99,10 +102,13 @@ pub async fn get_active_applications(owner: Option<String>, repo: Option<String>
99102
let conn = get_database_connection().await?;
100103
let mut query = Application::find()
101104
.filter(Column::PrNumber.ne(0));
102-
if let Some(owner) = owner {
105+
if let Some(owner) = owner.clone() {
103106
query = query.filter(Column::Owner.contains(owner));
104107
}
105108
if let Some(repo) = repo {
109+
if owner.is_none() {
110+
return Err(DbErr::Custom(format!("Owner is required to get merged applications").into()));
111+
}
106112
query = query.filter(Column::Repo.contains(repo));
107113
}
108114
query

0 commit comments

Comments
 (0)