Roomcount filter works now
This commit is contained in:
parent
a6cfcb89d0
commit
5f1823ab4f
|
@ -16,6 +16,7 @@ AND (LOWER(l.district) LIKE '%' || LOWER($2) || '%' OR $2 IS null) -- District F
|
|||
AND (p.project_type = $3 OR $3 IS null) -- ProjectType
|
||||
AND (p.project_condition = $4 OR $4 IS null) -- ProjectCondition
|
||||
AND (p.project_state = $5 OR $5 IS null) -- ProjectState
|
||||
AND ((SELECT COUNT(*) FROM unit u WHERE u.project_id = p.id AND u.rooms = $6) > 0 OR $6 IS NULL)
|
||||
-- End of filters
|
||||
ORDER BY p.time_created DESC
|
||||
LIMIT 50 OFFSET $6;
|
||||
LIMIT 50 OFFSET $7;
|
|
@ -90,6 +90,7 @@ pub async fn fetch_with_filters_paged(
|
|||
let mut project_type_filter = None;
|
||||
let mut project_state_filter = ProjectState::InConstruction;
|
||||
let mut project_condition_filter = None;
|
||||
let mut project_room_count_filter = None;
|
||||
|
||||
for filter in filters {
|
||||
match filter {
|
||||
|
@ -100,6 +101,9 @@ pub async fn fetch_with_filters_paged(
|
|||
Filter::ByProjectCondition(project_condition) => {
|
||||
project_condition_filter = Some(project_condition)
|
||||
}
|
||||
Filter::ByRoomCount(room_count) => {
|
||||
project_room_count_filter = Some(room_count)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,6 +115,7 @@ pub async fn fetch_with_filters_paged(
|
|||
project_type_filter as _,
|
||||
project_condition_filter as _,
|
||||
project_state_filter as _,
|
||||
project_room_count_filter as _,
|
||||
offset
|
||||
)
|
||||
.fetch_all(conn)
|
||||
|
|
|
@ -60,6 +60,7 @@ pub async fn get_project_data(
|
|||
) -> TypedHttpResponse<Listing> {
|
||||
services::read::get_project_data(&db_conn, &project_id).await
|
||||
}
|
||||
|
||||
#[post("/contact")]
|
||||
pub async fn create_contact_request(db_conn: web::Data<Arc<PgPool>>, contact: web::Json<ContactPayload>) -> TypedHttpResponse<()> {
|
||||
services::read::create_contact(&db_conn, contact.0).await
|
||||
|
@ -96,6 +97,13 @@ fn parse_params_into_filters(
|
|||
Err(_) => {}
|
||||
}
|
||||
}
|
||||
"byroomcount" => {
|
||||
let room_count = params.get(key).unwrap();
|
||||
match i32::from_str(&room_count) {
|
||||
Ok(room_count) => filters.push(Filter::ByRoomCount(room_count)),
|
||||
Err(_) => {},
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue