diff options
Diffstat (limited to 'src/purgatory/mod.rs')
| -rw-r--r-- | src/purgatory/mod.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/purgatory/mod.rs b/src/purgatory/mod.rs index fcb812b..11fe41f 100644 --- a/src/purgatory/mod.rs +++ b/src/purgatory/mod.rs | |||
| @@ -365,6 +365,33 @@ impl Purgatory { | |||
| 365 | }) | 365 | }) |
| 366 | } | 366 | } |
| 367 | 367 | ||
| 368 | /// Find all PR events for a specific repository identifier. | ||
| 369 | /// | ||
| 370 | /// PR events reference repositories via `a` tags with format `30617:<owner_pubkey>:<identifier>`. | ||
| 371 | /// This function scans all PR entries and returns those that reference the given identifier. | ||
| 372 | /// | ||
| 373 | /// Note: This is a linear scan since PR events are indexed by event_id, not by identifier. | ||
| 374 | /// For repositories with many PR events, this could be optimized with a secondary index. | ||
| 375 | /// | ||
| 376 | /// # Arguments | ||
| 377 | /// * `identifier` - The repository identifier to search for | ||
| 378 | /// | ||
| 379 | /// # Returns | ||
| 380 | /// Vector of PR purgatory entries that reference this identifier | ||
| 381 | pub fn find_prs_for_identifier(&self, identifier: &str) -> Vec<PrPurgatoryEntry> { | ||
| 382 | self.pr_events | ||
| 383 | .iter() | ||
| 384 | .filter(|entry| { | ||
| 385 | if let Some(ref event) = entry.value().event { | ||
| 386 | Self::event_references_identifier(event, identifier) | ||
| 387 | } else { | ||
| 388 | false | ||
| 389 | } | ||
| 390 | }) | ||
| 391 | .map(|entry| entry.value().clone()) | ||
| 392 | .collect() | ||
| 393 | } | ||
| 394 | |||
| 368 | /// Remove a state event from purgatory. | 395 | /// Remove a state event from purgatory. |
| 369 | /// | 396 | /// |
| 370 | /// Removes all entries for the given identifier. | 397 | /// Removes all entries for the given identifier. |