Fix critical mistake in intervals

This commit is contained in:
Sofia 2020-08-24 20:40:55 +03:00
parent c3ece41d81
commit a2a92d39eb
1 changed files with 18 additions and 18 deletions

View File

@ -187,7 +187,7 @@ impl API {
}
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 {
let location = locations[idx].clone();
@ -231,23 +231,6 @@ impl API {
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>(
list: &Vec<T>,
from: Option<NaiveDateTime>,
@ -288,6 +271,23 @@ impl API {
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> {
let response = minreq::get(url)
.with_header("content-type", "application/json")