feat: filter abnormal users

This commit is contained in:
mokurin000
2025-08-02 20:03:50 +08:00
parent 2415a7e029
commit c85c2101b7
2 changed files with 14 additions and 4 deletions

View File

@@ -88,6 +88,11 @@ pub enum Commands {
ScrapeAllB50 { ScrapeAllB50 {
#[arg(short, long, default_value_t = 5)] #[arg(short, long, default_value_t = 5)]
concurrency: usize, concurrency: usize,
#[arg(long, default_value_t = 1000)]
min_rating: i64,
#[arg(long, default_value_t = 16500)]
max_rating: i64,
}, },
#[cfg(feature = "fetchall")] #[cfg(feature = "fetchall")]
ListAllUserDump {}, ListAllUserDump {},

View File

@@ -263,18 +263,23 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
} }
#[cfg(feature = "fetchall")] #[cfg(feature = "fetchall")]
Commands::ScrapeAllB50 { concurrency } => { Commands::ScrapeAllB50 {
concurrency,
min_rating,
max_rating,
} => {
use sdgb_api::title::methods; use sdgb_api::title::methods;
use crate::{ use crate::{
cache::{PLAYER_B50, PLAYERS}, 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>( cached_concurrent_fetch::<methods::GetUserRatingApi>(
user_ids, players.iter().map(|p| p.user_id).collect::<Vec<u32>>(),
&client, &client,
concurrency, concurrency,
PLAYER_B50, PLAYER_B50,