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)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct Card {
|
struct Card {
|
||||||
cardId: String,
|
cardId: String,
|
||||||
|
locked: bool,
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct Car {
|
struct Car {
|
||||||
|
|
@ -40,6 +41,7 @@ struct BestCarRecord {
|
||||||
config: String,
|
config: String,
|
||||||
time: f64,
|
time: f64,
|
||||||
owned: bool,
|
owned: bool,
|
||||||
|
guid: String,
|
||||||
}
|
}
|
||||||
type TripletKey = (String, u8, String); // (Track ID, RQ, Surface)
|
type TripletKey = (String, u8, String); // (Track ID, RQ, Surface)
|
||||||
static BEST_CARS: Lazy<Mutex<HashMap<TripletKey, Vec<BestCarRecord>>>> =
|
static BEST_CARS: Lazy<Mutex<HashMap<TripletKey, Vec<BestCarRecord>>>> =
|
||||||
|
|
@ -69,6 +71,10 @@ async fn main() {
|
||||||
parse_all_times().await;
|
parse_all_times().await;
|
||||||
print_best_cars(true);
|
print_best_cars(true);
|
||||||
}
|
}
|
||||||
|
"trash" => {
|
||||||
|
parse_all_times().await;
|
||||||
|
print_trash();
|
||||||
|
}
|
||||||
"details" => {
|
"details" => {
|
||||||
parse_all_times().await;
|
parse_all_times().await;
|
||||||
print_best_times();
|
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() {
|
fn print_best_times() {
|
||||||
let best_cars = BEST_CARS.lock().unwrap();
|
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 owned = my_cars.contains(&car.guid);
|
||||||
|
let guid = car.guid.clone();
|
||||||
|
|
||||||
// Insert into the database
|
// Insert into the database
|
||||||
if time > 1.2 && no_down_votes {
|
if time > 1.2 && no_down_votes {
|
||||||
|
|
@ -221,6 +247,7 @@ async fn parse_car_times(car: Car) {
|
||||||
config: config.clone(),
|
config: config.clone(),
|
||||||
time,
|
time,
|
||||||
owned,
|
owned,
|
||||||
|
guid,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -329,7 +356,7 @@ fn get_my_car_list() -> Vec<String> {
|
||||||
let deck_json = json.get("playerDeck").ok_or("Missing 'playerDeck'");
|
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.");
|
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() {
|
async fn get_tracks_file() {
|
||||||
println!("Fetching tracks file...");
|
println!("Fetching tracks file...");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue