(
&mut self,
client: &Client,
repo_id: RepoId,
before: &Option<RepoTopic>,
after: &RepoTopic,
)
| 840 | } |
| 841 | |
| 842 | pub fn update_synonyms( |
| 843 | &mut self, |
| 844 | client: &Client, |
| 845 | repo_id: RepoId, |
| 846 | before: &Option<RepoTopic>, |
| 847 | after: &RepoTopic, |
| 848 | ) -> Result<()> { |
| 849 | let topic_id = after.topic_id(); |
| 850 | |
| 851 | let before = match before { |
| 852 | Some(before) => before |
| 853 | .prefixed_synonyms() |
| 854 | .iter() |
| 855 | .cloned() |
| 856 | .collect::<HashSet<Synonym>>(), |
| 857 | None => HashSet::new(), |
| 858 | }; |
| 859 | |
| 860 | let after = after |
| 861 | .prefixed_synonyms() |
| 862 | .iter() |
| 863 | .cloned() |
| 864 | .collect::<HashSet<Synonym>>(); |
| 865 | |
| 866 | self.synonym_indexes( |
| 867 | client, |
| 868 | repo_id, |
| 869 | after.difference(&before), |
| 870 | |index, token, name| { |
| 871 | index.add(topic_id, token.to_owned(), name)?; |
| 872 | Ok(()) |
| 873 | }, |
| 874 | )?; |
| 875 | |
| 876 | self.synonym_indexes( |
| 877 | client, |
| 878 | repo_id, |
| 879 | before.difference(&after), |
| 880 | |index, token, name| { |
| 881 | index.remove(topic_id, token.to_owned(), name)?; |
| 882 | Ok(()) |
| 883 | }, |
| 884 | )?; |
| 885 | |
| 886 | Ok(()) |
| 887 | } |
| 888 | } |
| 889 | |
| 890 | impl std::fmt::Debug for Indexer { |
no test coverage detected