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

View File

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