(&self, client: &Client, fetch: &F)
| 403 | } |
| 404 | |
| 405 | fn fetch_downset<F>(&self, client: &Client, fetch: &F) -> Result<BTreeSet<SearchMatch>> |
| 406 | where |
| 407 | F: Downset, |
| 408 | { |
| 409 | let topic_ids = self.intersection(client, fetch)?; |
| 410 | log::info!( |
| 411 | "search: fetching topic downset ({} paths) in repos {:?}", |
| 412 | topic_ids.len(), |
| 413 | self.viewer.read_repo_ids |
| 414 | ); |
| 415 | |
| 416 | let mut objects = ObjectBuilders::new(); |
| 417 | |
| 418 | // Ensure that the wiki repo id is a the end of the list so that private items appear at the |
| 419 | // top of search results; |
| 420 | let wiki_repo_id = RepoId::wiki(); |
| 421 | let mut repo_ids = self |
| 422 | .viewer |
| 423 | .read_repo_ids |
| 424 | .iter() |
| 425 | .cloned() |
| 426 | .collect::<Vec<RepoId>>(); |
| 427 | repo_ids.sort_by_key(|repo_id| repo_id == &wiki_repo_id); |
| 428 | |
| 429 | for &repo_id in repo_ids.iter() { |
| 430 | log::info!("search: looking within {:?} for {:?}", repo_id, self.search); |
| 431 | for topic_id in topic_ids.iter().take(self.limit) { |
| 432 | if let Some(repo_object) = client.fetch(repo_id, topic_id) { |
| 433 | let key = Okey(topic_id.to_owned(), self.context_repo_id); |
| 434 | objects.add(key, repo_id, repo_object); |
| 435 | } |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | objects |
| 440 | .finalize()? |
| 441 | .into_matches(&self.search, self.locale, self.limit) |
| 442 | } |
| 443 | |
| 444 | fn intersection<F>(&self, client: &Client, fetch: &F) -> Result<HashSet<ExternalId>> |
| 445 | where |
no test coverage detected