feat: filter abnormal users
This commit is contained in:
@@ -88,6 +88,11 @@ pub enum Commands {
|
||||
ScrapeAllB50 {
|
||||
#[arg(short, long, default_value_t = 5)]
|
||||
concurrency: usize,
|
||||
|
||||
#[arg(long, default_value_t = 1000)]
|
||||
min_rating: i64,
|
||||
#[arg(long, default_value_t = 16500)]
|
||||
max_rating: i64,
|
||||
},
|
||||
#[cfg(feature = "fetchall")]
|
||||
ListAllUserDump {},
|
||||
|
||||
@@ -263,18 +263,23 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "fetchall")]
|
||||
Commands::ScrapeAllB50 { concurrency } => {
|
||||
Commands::ScrapeAllB50 {
|
||||
concurrency,
|
||||
min_rating,
|
||||
max_rating,
|
||||
} => {
|
||||
use sdgb_api::title::methods;
|
||||
|
||||
use crate::{
|
||||
cache::{PLAYER_B50, PLAYERS},
|
||||
utils::helpers::{cached_concurrent_fetch, read_cache_keys},
|
||||
utils::helpers::{cached_concurrent_fetch, read_cache},
|
||||
};
|
||||
|
||||
let user_ids = read_cache_keys(PLAYERS)?;
|
||||
let mut players: Vec<GetUserPreviewApiResp> = read_cache(PLAYERS)?;
|
||||
players.retain(|p| p.player_rating >= min_rating && p.player_rating <= max_rating);
|
||||
|
||||
cached_concurrent_fetch::<methods::GetUserRatingApi>(
|
||||
user_ids,
|
||||
players.iter().map(|p| p.user_id).collect::<Vec<u32>>(),
|
||||
&client,
|
||||
concurrency,
|
||||
PLAYER_B50,
|
||||
|
||||
Reference in New Issue
Block a user