refactor: split userid read & fetch
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
use std::{fs::OpenOptions, io::BufWriter};
|
||||
use std::{
|
||||
io::{self, BufRead},
|
||||
path::Path,
|
||||
sync::atomic::Ordering,
|
||||
};
|
||||
use std::{path::Path, sync::atomic::Ordering};
|
||||
|
||||
use futures_util::StreamExt;
|
||||
use nyquest_preset::nyquest::AsyncClient;
|
||||
@@ -70,6 +66,7 @@ where
|
||||
}
|
||||
|
||||
pub async fn cached_concurrent_fetch<A: APIExt>(
|
||||
user_ids: impl Into<Vec<u32>>,
|
||||
client: &AsyncClient,
|
||||
concurrency: usize,
|
||||
definition: TableDefinition<'_, u32, Vec<u8>>,
|
||||
@@ -78,22 +75,7 @@ where
|
||||
A::Payload: From<u32>,
|
||||
A::Response: Encode + for<'a> BorrowDecode<'a, ()> + HasUid,
|
||||
{
|
||||
let mut user_ids = Vec::new();
|
||||
{
|
||||
let mut stdin = 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);
|
||||
}
|
||||
}
|
||||
|
||||
let user_ids = user_ids.into();
|
||||
let _ = cache::init_db();
|
||||
let read = cache::read_txn()?;
|
||||
let write = cache::write_txn()?;
|
||||
|
||||
Reference in New Issue
Block a user