use crate::constants::{ self };
use super::models::GitPullRequestSearchCriteria;
pub(crate) fn pr_criteria_params(c: &GitPullRequestSearchCriteria) -> Vec<(String, String)> {
let mut p = Vec::new();
if let Some(ref v) = c.repository_id {
p.push((
format!("{}{}", constants::query::SEARCH_PFX, constants::query::REPOSITORY_ID),
v.clone(),
));
}
if let Some(ref v) = c.creator_id {
p.push((
format!("{}{}", constants::query::SEARCH_PFX, constants::query::CREATOR_ID),
v.clone(),
));
}
if let Some(ref v) = c.reviewer_id {
p.push((
format!("{}{}", constants::query::SEARCH_PFX, constants::query::REVIEWER_ID),
v.clone(),
));
}
if let Some(ref v) = c.source_ref_name {
p.push((
format!("{}{}", constants::query::SEARCH_PFX, constants::query::SOURCE_REF_NAME),
v.clone(),
));
}
if let Some(ref v) = c.target_ref_name {
p.push((
format!("{}{}", constants::query::SEARCH_PFX, constants::query::TARGET_REF_NAME),
v.clone(),
));
}
if let Some(ref v) = c.source_repository_id {
p.push((
format!("{}{}", constants::query::SEARCH_PFX, constants::query::SOURCE_REPOSITORY_ID),
v.clone(),
));
}
if let Some(ref v) = c.status {
p.push((
format!("{}{}", constants::query::SEARCH_PFX, constants::query::STATUS),
crate::util::enum_to_str(&v),
));
}
p
}