Added trash feature
This commit is contained in:
parent
48e623a1a3
commit
b8433909fd
1 changed files with 28 additions and 1 deletions
|
|
@ -20,6 +20,7 @@ use serde::Deserialize;
|
|||
#[derive(Debug, Deserialize)]
|
||||
struct Card {
|
||||
cardId: String,
|
||||
locked: bool,
|
||||
}
|
||||
#[derive(Debug, Clone)]
|
||||
struct Car {
|
||||
|
|
@ -40,6 +41,7 @@ struct BestCarRecord {
|
|||
config: String,
|
||||
time: f64,
|
||||
owned: bool,
|
||||
guid: String,
|
||||
}
|
||||
type TripletKey = (String, u8, String); // (Track ID, RQ, Surface)
|
||||
static BEST_CARS: Lazy<Mutex<HashMap<TripletKey, Vec<BestCarRecord>>>> =
|
||||
|
|
@ -69,6 +71,10 @@ async fn main() {
|
|||
parse_all_times().await;
|
||||
print_best_cars(true);
|
||||
}
|
||||
"trash" => {
|
||||
parse_all_times().await;
|
||||
print_trash();
|
||||
}
|
||||
"details" => {
|
||||
parse_all_times().await;
|
||||
print_best_times();
|
||||
|
|
@ -91,6 +97,25 @@ async fn main() {
|
|||
}
|
||||
}
|
||||
}
|
||||
fn print_trash() {
|
||||
let best_cars: Vec<_> = BEST_CARS.lock().unwrap().values().flat_map(|records| records.iter().map(|record| record.guid.clone())).collect();
|
||||
|
||||
for my_car in get_my_car_list() {
|
||||
if ! best_cars.contains(&my_car) {
|
||||
for bad_car in get_car_list() {
|
||||
if bad_car.guid == my_car {
|
||||
println!("{},{},{},{}",
|
||||
bad_car.rq,
|
||||
bad_car.brand,
|
||||
bad_car.only_name,
|
||||
bad_car.year
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn print_best_times() {
|
||||
let best_cars = BEST_CARS.lock().unwrap();
|
||||
|
||||
|
|
@ -205,6 +230,7 @@ async fn parse_car_times(car: Car) {
|
|||
}
|
||||
|
||||
let owned = my_cars.contains(&car.guid);
|
||||
let guid = car.guid.clone();
|
||||
|
||||
// Insert into the database
|
||||
if time > 1.2 && no_down_votes {
|
||||
|
|
@ -221,6 +247,7 @@ async fn parse_car_times(car: Car) {
|
|||
config: config.clone(),
|
||||
time,
|
||||
owned,
|
||||
guid,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
@ -329,7 +356,7 @@ fn get_my_car_list() -> Vec<String> {
|
|||
let deck_json = json.get("playerDeck").ok_or("Missing 'playerDeck'");
|
||||
let cards: Vec<Card> = serde_json::from_value(deck_json.clone().expect("Could not extract cards.").clone()).expect("Could not extract cards.");
|
||||
|
||||
cards.into_iter().map(|card| card.cardId).collect()
|
||||
cards.into_iter() .filter(|card| card.locked).map(|card| card.cardId).collect()
|
||||
}
|
||||
async fn get_tracks_file() {
|
||||
println!("Fetching tracks file...");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue