make some neatness changes

This commit is contained in:
Sofia 2020-08-24 20:37:36 +03:00
parent 8187f1e184
commit c3ece41d81
2 changed files with 17 additions and 23 deletions

View File

@ -209,9 +209,7 @@ impl API {
} else {
while awaiting > 0 {
if let Ok((loc, rec)) = i_receiver.try_recv() {
if API::add_error_back(loc, &rec, &mut locations) {
println!("Sent back to queue");
}
API::add_error_back(loc, &rec, &mut locations);
awaiting -= 1;
sender.send(rec).ok();
}
@ -222,9 +220,7 @@ impl API {
}
} else {
if let Ok((loc, rec)) = i_receiver.try_recv() {
if API::add_error_back(loc, &rec, &mut locations) {
println!("Sent back to queue");
}
API::add_error_back(loc, &rec, &mut locations);
awaiting -= 1;
sender.send(rec).ok();
}

View File

@ -118,25 +118,23 @@ fn run(
loop {
match receiver.try_recv() {
Ok(res) => match res {
Ok(loc) => {
if loc.is_ok() {
Ok(loc) => match loc {
Ok(mut loc) => {
counter += 1;
let remaining = exp_time(&api, states.len() as u64 - counter as u64);
print!(
"Done: {:<5.2}% Remaining: {:<5.2} seconds\r",
counter as f32 / states.len() as f32 * 100.,
remaining.as_secs_f32()
);
std::io::stdout().lock().flush().ok();
locations.append(&mut loc);
}
let remaining = exp_time(&api, states.len() as u64 - counter as u64);
print!(
"Done: {:<5.2}% Remaining: {:<5.2} seconds\r",
counter as f32 / states.len() as f32 * 100.,
remaining.as_secs_f32()
);
std::io::stdout().lock().flush().ok();
match loc {
Ok(mut loc) => locations.append(&mut loc),
Err(e) => eprintln!(
"Error fetching location data: {}",
e.message.unwrap_or(String::new())
),
}
}
Err(e) => eprintln!(
"Error fetching location data: {}",
e.message.unwrap_or(String::new())
),
},
Err(e) => eprintln!("{}", e),
},
Err(e) => {