Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions server/bleep/src/indexes/analytics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,17 @@ impl StatsGatherer {
self.stats_tx.clone()
}

#[rustfmt::skip]
pub async fn finish(mut self) -> RepoEvent {
pub async fn finish(&mut self) {
// aggregate stats
self.stats_rx.close();
while let Some(stats) = self.stats_rx.recv().await {
self.repo_stats += stats;
}
}

// Consume self to produce analytics event
#[rustfmt::skip]
pub fn event(mut self) -> RepoEvent {
// determine the type of index job run
//
let job_kind = if self.was_index_reset {
Expand All @@ -86,7 +89,6 @@ impl StatsGatherer {
reindex_file_count: self.repo_stats.reindex_count,
}
};

self.event.add_payload("reporef", &self.reporef.name());
self.event.add_payload("provider", &self.reporef.backend());
self.event.add_payload("index_job_kind", &job_kind);
Expand Down
3 changes: 2 additions & 1 deletion server/bleep/src/indexes/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,10 @@ impl Indexable for File {

info!(?repo.disk_path, "repo file indexing finished, took {:?}", start.elapsed());

stats_gatherer.finish().await;
if stats_gatherer.repo_stats.reindex_count > 0 {
let user = app.user().await;
let event = stats_gatherer.finish().await;
let event = stats_gatherer.event();
app.with_analytics(|hub| hub.track_repo(event, &user));
}

Expand Down