Created
August 10, 2022 03:19
-
-
Save Seeker14491/0c9c2299c828b313096dfbbb609abffe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use eyre::{Error, Result}; | |
use futures::{stream::FuturesUnordered, StreamExt, TryStreamExt}; | |
use std::time::Instant; | |
use steamworks::ugc::MatchingUgcType; | |
#[tokio::main(flavor = "current_thread")] | |
async fn main() -> Result<()> { | |
let steam = steamworks::Client::init(Some(233610))?; | |
let sprint_workshop_levels: Vec<_> = steam | |
.query_all_ugc(MatchingUgcType::ItemsReadyToUse) | |
.required_tag("Sprint") | |
.run() | |
.try_collect() | |
.await?; | |
println!("Finished querying workshop levels"); | |
let start_instant = Instant::now(); | |
let leaderboard_names = sprint_workshop_levels.iter().filter_map(|details| { | |
distance_util::create_leaderboard_name_string( | |
details.file_name.trim_end_matches(".bytes"), | |
distance_util::LeaderboardGameMode::Sprint, | |
Some(details.steam_id_owner.as_u64()), | |
) | |
.ok() | |
}); | |
let entries: Vec<_> = leaderboard_names | |
.map(|name| async { | |
let leaderboard = steam.find_leaderboard(name).await.ok()?; | |
let entries = leaderboard.download_global_around_user(0, 0, 0).await; | |
entries.into_iter().next().map(Ok::<_, Error>) | |
}) | |
.collect::<FuturesUnordered<_>>() | |
.filter_map(|x| async { x }) | |
.try_collect() | |
.await?; | |
let duration = Instant::now().duration_since(start_instant); | |
println!("{:?}", &entries); | |
println!("{} seconds", duration.as_secs()); | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment