Skip to content

Commit

Permalink
cache-github-org-collect
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaydubina committed Mar 18, 2024
1 parent 4478a7e commit 33f1386
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "landscape2-academic"
description = "Landscape2 Academic CLI tool"
version = "0.8.0"
version = "0.8.1"
license = "Apache-2.0"
edition = "2021"
rust-version = "1.70"
Expand Down
10 changes: 9 additions & 1 deletion src/build/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ pub(crate) async fn collect_github_org_data(
) -> Result<GithubOrgData> {
debug!("collecting github org information from github (this may take a while)");

let mut cached_data: Option<GithubOrgData> = None;
match cache.read(GITHUB_ORG_CACHE_FILE) {
Ok(Some((_, json_data))) => match serde_json::from_slice(&json_data) {
Ok(github_data) => return Ok(github_data),
Ok(github_data) => cached_data = Some(github_data),
Err(err) => warn!("error parsing github cache file: {err:?}"),
},
Ok(None) => {}
Expand Down Expand Up @@ -167,6 +168,13 @@ pub(crate) async fn collect_github_org_data(

for item in &landscape_data.items {
if let Some(url) = &item.github_org_url {
if let Some(ref cache) = cached_data {
if cache.contains_key(url) {
github_org_stats.insert(url.to_string(), cache.get(url).unwrap().clone());
continue;
}
}

if let Some(gh_pool) = &gh_pool {
let gh = gh_pool.get().await.expect("token -when available-");
github_org_stats.insert(url.to_string(), GithubOrganizationStats::new(gh, url).await?);
Expand Down

0 comments on commit 33f1386

Please sign in to comment.