refactor: split userid read & fetch
This commit is contained in:
@@ -232,10 +232,28 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
||||
|
||||
#[cfg(feature = "fetchall")]
|
||||
Commands::ListAllUser { concurrency } => {
|
||||
use sdgb_api::title::methods::GetUserPreviewApi;
|
||||
|
||||
use crate::{cache::PLAYERS, utils::helpers::cached_concurrent_fetch};
|
||||
cached_concurrent_fetch::<GetUserPreviewApi>(&client, concurrency, PLAYERS).await?;
|
||||
use sdgb_api::title::methods::GetUserPreviewApi;
|
||||
use std::io::BufRead as _;
|
||||
|
||||
let mut user_ids = Vec::new();
|
||||
{
|
||||
let mut stdin = std::io::stdin().lock();
|
||||
let mut buf = String::new();
|
||||
|
||||
while stdin.read_line(&mut buf).is_ok_and(|size| size != 0) {
|
||||
if buf.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let user_id: u32 = buf.trim().parse()?;
|
||||
buf.clear();
|
||||
user_ids.push(user_id);
|
||||
}
|
||||
}
|
||||
|
||||
cached_concurrent_fetch::<GetUserPreviewApi>(user_ids, &client, concurrency, PLAYERS)
|
||||
.await?;
|
||||
}
|
||||
#[cfg(feature = "fetchall")]
|
||||
Commands::ListAllUserDump {} => {
|
||||
@@ -244,6 +262,14 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
|
||||
dump_cache::<GetUserPreviewApiResp>("players.json", PLAYERS)?;
|
||||
}
|
||||
|
||||
#[cfg(feature = "fetchall")]
|
||||
Commands::ScrapeAllB50 { concurrency } => {
|
||||
use crate::{
|
||||
cache::PLAYERS,
|
||||
utils::helpers::{cached_concurrent_fetch, read_cache},
|
||||
};
|
||||
}
|
||||
|
||||
Commands::Userdata { user_id } => {
|
||||
let action = async |_| match Sdgb1_50::request::<_, GetUserDataApiResp>(
|
||||
&client,
|
||||
|
||||
Reference in New Issue
Block a user