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,25 +118,23 @@ 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);
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); Err(e) => eprintln!(
print!( "Error fetching location data: {}",
"Done: {:<5.2}% Remaining: {:<5.2} seconds\r", e.message.unwrap_or(String::new())
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!("{}", e), Err(e) => eprintln!("{}", e),
}, },
Err(e) => { Err(e) => {