(
mutation: &mut Mutation,
repo_link_repo_id: RepoId,
repo_link: &mut RepoLink,
parent_topics: &Vec<ParentTopicRow>,
)
| 455 | } |
| 456 | |
| 457 | fn persist_link( |
| 458 | mutation: &mut Mutation, |
| 459 | repo_link_repo_id: RepoId, |
| 460 | repo_link: &mut RepoLink, |
| 461 | parent_topics: &Vec<ParentTopicRow>, |
| 462 | ) -> Result<()> { |
| 463 | let mut topics = BTreeSet::new(); |
| 464 | |
| 465 | for parent in parent_topics { |
| 466 | let parent_repo_id = RepoId::try_from(&parent.repository_id).unwrap(); |
| 467 | if repo_link_repo_id != parent_repo_id { |
| 468 | continue; |
| 469 | } |
| 470 | |
| 471 | let id = sha256_id(&parent.id); |
| 472 | topics.insert(activity::TopicInfo::from(( |
| 473 | Locale::EN, |
| 474 | parent.name.to_owned(), |
| 475 | id, |
| 476 | ))); |
| 477 | } |
| 478 | |
| 479 | let change = activity::Change::ImportLink(activity::ImportLink { |
| 480 | actor_id: "461c87c8-fb8f-11e8-9cbc-afde6c54d881".to_owned(), |
| 481 | date: chrono::Utc::now(), |
| 482 | id: activity::Change::new_id(), |
| 483 | imported_link: activity::LinkInfo::from(&*repo_link), |
| 484 | parent_topics: activity::TopicInfoList::from(topics), |
| 485 | }); |
| 486 | |
| 487 | mutation.save_link(repo_link_repo_id, repo_link).unwrap(); |
| 488 | mutation.add_change(repo_link_repo_id, &change).unwrap(); |
| 489 | |
| 490 | Ok(()) |
| 491 | } |
| 492 | |
| 493 | fn persist_links( |
| 494 | mutation: &mut Mutation, |
no test coverage detected