Fix critical mistake in intervals

This commit is contained in:
Sofia 2020-08-24 20:40:55 +03:00
parent c3ece41d81
commit a2a92d39eb

View File

@ -187,7 +187,7 @@ impl API {
} }
last_time = now; last_time = now;
if awaiting <= config.throttle && timer < (interval * (config.throttle as u128 + 2)) if awaiting <= config.throttle && timer < (interval * (config.throttle as u128 - 2))
{ {
if locations.len() > idx { if locations.len() > idx {
let location = locations[idx].clone(); let location = locations[idx].clone();
@ -231,23 +231,6 @@ impl API {
receiver receiver
} }
fn add_error_back(
location: String,
rec: &Result<Result<Vec<LocationModel>, ErrorModel>, GenericError>,
locations: &mut Vec<String>,
) -> bool {
if let Ok(inner) = rec {
if let Err(_) = inner {
locations.push(location);
true
} else {
false
}
} else {
false
}
}
pub fn get_between<T: Timestamped + Clone>( pub fn get_between<T: Timestamped + Clone>(
list: &Vec<T>, list: &Vec<T>,
from: Option<NaiveDateTime>, from: Option<NaiveDateTime>,
@ -288,6 +271,23 @@ impl API {
timestamped timestamped
} }
fn add_error_back(
location: String,
rec: &Result<Result<Vec<LocationModel>, ErrorModel>, GenericError>,
locations: &mut Vec<String>,
) -> bool {
if let Ok(inner) = rec {
if let Err(_) = inner {
locations.push(location);
true
} else {
false
}
} else {
false
}
}
fn request(&mut self, url: String) -> Result<Response, GenericError> { fn request(&mut self, url: String) -> Result<Response, GenericError> {
let response = minreq::get(url) let response = minreq::get(url)
.with_header("content-type", "application/json") .with_header("content-type", "application/json")