* Flattening /message/time_range handler further dfc-chan returns

This commit is contained in:
shockrah 2021-01-23 13:36:30 -08:00
parent 5855387a52
commit b9573ee09c

View File

@ -32,8 +32,7 @@ pub async fn get_by_time(pool: &Pool, response: &mut Response<Body>, params: Val
None => None
};
// TODO: flatten me mommy
match (channel, start_time, end_time) {
(Some(channel), Some(start), Some(end)) => {
if let (Some(channel), Some(start), Some(end)) = (channel, start_time, end_time) {
match Message::get_time_range(pool, channel, start, end).await {
Ok(db_response) => {
match db_response {
@ -48,16 +47,16 @@ pub async fn get_by_time(pool: &Pool, response: &mut Response<Body>, params: Val
_ => *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR
};
// this absolute lack of data streaming is prolly gonna suck like
// a whoe in hell week for performance but lets pretend servers don't get massive
// a whore in hell week for performance but lets pretend servers don't get massive
},
Err(e) => {
eprintln!("{}", e);
*response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
}
};
},
_ => *response.status_mut() = StatusCode::BAD_REQUEST
};
} else {
*response.status_mut() = StatusCode::BAD_REQUEST;
}
}
pub async fn send_message(pool: &Pool, response: &mut Response<Body>, params: Value) {