Extract ui api requests to common functions

This commit is contained in:
2023-09-17 09:35:03 -04:00
parent 4a3225c3f9
commit 5443ed6d77
6 changed files with 43 additions and 21 deletions

View File

@@ -43,8 +43,16 @@ pub struct QueryAirport {
}
impl QueryAirport {
pub fn get_all(bounds: Option<Polygon<Point>>, category: Option<String>, filter: Option<String>, limit: i32, page: i32) -> Result<Vec<Self>, ServiceError> {
pub fn get_all(bounds: Option<Polygon<Point>>, category: Option<String>, filter: Option<String>, limit: Option<i32>, page: Option<i32>) -> Result<Vec<Self>, ServiceError> {
let mut conn = db::connection()?;
let limit = match limit {
Some(l) => l,
None => 100
};
let page = match page {
Some(p) => p,
None => 1
};
let mut query = airports::table
.limit(limit as i64)
.into_boxed();

View File

@@ -9,8 +9,8 @@ struct GetAllParameters {
filter: Option<String>,
bounds: Option<String>,
category: Option<String>,
limit: i32,
page: i32
limit: Option<i32>,
page: Option<i32>
}
#[get("/import")]