| 409 | } |
| 410 | |
| 411 | pub async fn upsert_topic( |
| 412 | &self, |
| 413 | graphql::UpsertTopicInput { |
| 414 | name, |
| 415 | repo_id, |
| 416 | parent_topic_id, |
| 417 | on_matching_synonym, |
| 418 | update_topic_id, |
| 419 | .. |
| 420 | }: graphql::UpsertTopicInput, |
| 421 | ) -> Result<git::UpsertTopicResult> { |
| 422 | let parent_topic = ExternalId::try_from(&parent_topic_id)?; |
| 423 | |
| 424 | let on_matching_synonym = match &(on_matching_synonym, update_topic_id) { |
| 425 | (graphql::OnMatchingSynonym::Ask, None) => git::OnMatchingSynonym::Ask, |
| 426 | |
| 427 | (graphql::OnMatchingSynonym::CreateDistinct, None) => { |
| 428 | git::OnMatchingSynonym::CreateDistinct |
| 429 | } |
| 430 | |
| 431 | (graphql::OnMatchingSynonym::Update, Some(topic_id)) => { |
| 432 | git::OnMatchingSynonym::Update(topic_id.try_into()?) |
| 433 | } |
| 434 | |
| 435 | (enum_value, update_topic_id) => { |
| 436 | log::warn!( |
| 437 | "unrecognized upsert topic resolution: {:?} / {:?}", |
| 438 | enum_value, |
| 439 | update_topic_id, |
| 440 | ); |
| 441 | git::OnMatchingSynonym::Ask |
| 442 | } |
| 443 | }; |
| 444 | |
| 445 | git::UpsertTopic { |
| 446 | actor: Arc::clone(&self.viewer), |
| 447 | locale: Locale::EN, |
| 448 | name, |
| 449 | on_matching_synonym, |
| 450 | repo_id: repo_id.try_into()?, |
| 451 | parent_topic_id: parent_topic, |
| 452 | } |
| 453 | .call(self.mutation()?, &self.redis) |
| 454 | } |
| 455 | |
| 456 | pub async fn upsert_topic_timerange( |
| 457 | &self, |