MCPcopy Index your code
hub / github.com/emwalker/digraph / call

Method call

backend/src/git/stats.rs:60–108  ·  view source on GitHub ↗
(&self, git: &Client, cache: &C)

Source from the content-addressed store, hash-verified

58
59impl FetchStats {
60 pub async fn call<C>(&self, git: &Client, cache: &C) -> Result<FetchStatsResult>
61 where
62 C: CacheStats + Clone + Send + std::fmt::Debug + 'static,
63 {
64 let mut stats = vec![];
65
66 for &repo_id in self.viewer.read_repo_ids.iter() {
67 let view = git.view(repo_id)?;
68
69 let commit = view.commit.to_string();
70 let s = match cache.fetch(repo_id, &commit)? {
71 Some(stats) => stats,
72
73 None => {
74 let stats = RepoStats {
75 computing: true,
76 link_count: None,
77 topic_count: None,
78 };
79 // Save a placeholder that will be updated with the computed values. Expires
80 // after 180 seconds in case something happens and it should be retried.
81 cache.save(repo_id, &commit, &stats, Some(120))?;
82
83 // let view = view.duplicate()?;
84 // let cache = cache.to_owned();
85 // let commit = commit.to_owned();
86 // let prefix = repo_id.to_owned();
87
88 // let _ = actix_web::web::block(move || {
89 // let key = format!("{}:{}", prefix, commit);
90 // log::info!("computing stats for {} ...", key);
91 // let stats = view.stats().expect("failed to fetch stats");
92 // cache
93 // .save(&prefix, &commit, &stats, None)
94 // .expect("failed to save stats");
95 // log::info!("stats for {} saved to cache", key);
96 // });
97
98 stats
99 }
100 };
101
102 stats.push(s);
103 }
104
105 Ok(FetchStatsResult {
106 stats: Stats { stats },
107 })
108 }
109}

Callers

nothing calls this directly

Calls 4

saveMethod · 0.80
iterMethod · 0.45
viewMethod · 0.45
fetchMethod · 0.45

Tested by

no test coverage detected