diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-26 21:13:29 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-26 21:13:29 +0000 |
| commit | 76a5e7b46dbe90ebf5e31904cb510e6cab242cf4 (patch) | |
| tree | 49520a18cb4e964b4218548e22383b1ed196277a /src/lib | |
| parent | a94fbc1f616128c93539c71b003495e5f6291c69 (diff) | |
feat: track and display kind-5 deletion count in FetchReport
Add a deletions counter to FetchReport, incremented in
process_fetched_events for each kind-5 event received and accumulated
across relays in consolidate_fetch_reports. The count is included in
the fetch summary display (e.g. "1 deletion", "2 deletions").
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/client.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/client.rs b/src/lib/client.rs index 95dd78d..634dce2 100644 --- a/src/lib/client.rs +++ b/src/lib/client.rs | |||
| @@ -1962,6 +1962,8 @@ async fn process_fetched_events( | |||
| 1962 | report.updated_state = Some((event.created_at, event.id)); | 1962 | report.updated_state = Some((event.created_at, event.id)); |
| 1963 | } | 1963 | } |
| 1964 | } | 1964 | } |
| 1965 | } else if event.kind.eq(&Kind::EventDeletion) { | ||
| 1966 | report.deletions += 1; | ||
| 1965 | } else if event_is_patch_set_root(event) || event.kind.eq(&KIND_PULL_REQUEST) { | 1967 | } else if event_is_patch_set_root(event) || event.kind.eq(&KIND_PULL_REQUEST) { |
| 1966 | fresh_proposal_roots.insert(event.id); | 1968 | fresh_proposal_roots.insert(event.id); |
| 1967 | report.proposals.insert(event.id); | 1969 | report.proposals.insert(event.id); |
| @@ -2064,6 +2066,7 @@ pub fn consolidate_fetch_reports(reports: Vec<Result<FetchReport>>) -> FetchRepo | |||
| 2064 | for c in relay_report.statuses { | 2066 | for c in relay_report.statuses { |
| 2065 | report.statuses.insert(c); | 2067 | report.statuses.insert(c); |
| 2066 | } | 2068 | } |
| 2069 | report.deletions += relay_report.deletions; | ||
| 2067 | for c in relay_report.contributor_profiles { | 2070 | for c in relay_report.contributor_profiles { |
| 2068 | report.contributor_profiles.insert(c); | 2071 | report.contributor_profiles.insert(c); |
| 2069 | } | 2072 | } |
| @@ -2234,6 +2237,8 @@ pub struct FetchReport { | |||
| 2234 | /// commits against existing propoals | 2237 | /// commits against existing propoals |
| 2235 | commits: HashSet<EventId>, | 2238 | commits: HashSet<EventId>, |
| 2236 | statuses: HashSet<EventId>, | 2239 | statuses: HashSet<EventId>, |
| 2240 | /// Count of kind-5 deletion events received (for display purposes). | ||
| 2241 | deletions: u32, | ||
| 2237 | contributor_profiles: HashSet<PublicKey>, | 2242 | contributor_profiles: HashSet<PublicKey>, |
| 2238 | profile_updates: HashSet<PublicKey>, | 2243 | profile_updates: HashSet<PublicKey>, |
| 2239 | /// The best (newest) state event seen on each relay during the fetch. | 2244 | /// The best (newest) state event seen on each relay during the fetch. |
| @@ -2295,6 +2300,13 @@ impl Display for FetchReport { | |||
| 2295 | if self.statuses.len() > 1 { "es" } else { "" }, | 2300 | if self.statuses.len() > 1 { "es" } else { "" }, |
| 2296 | )); | 2301 | )); |
| 2297 | } | 2302 | } |
| 2303 | if self.deletions > 0 { | ||
| 2304 | display_items.push(format!( | ||
| 2305 | "{} deletion{}", | ||
| 2306 | self.deletions, | ||
| 2307 | if self.deletions > 1 { "s" } else { "" }, | ||
| 2308 | )); | ||
| 2309 | } | ||
| 2298 | if !self.contributor_profiles.is_empty() { | 2310 | if !self.contributor_profiles.is_empty() { |
| 2299 | display_items.push(format!( | 2311 | display_items.push(format!( |
| 2300 | "{} user profile{}", | 2312 | "{} user profile{}", |