MCPcopy Create free account
hub / github.com/emwalker/digraph / persist_topic

Function persist_topic

backend/src/bin/export.rs:201–271  ·  view source on GitHub ↗
(
    mutation: &mut Mutation,
    repo_topic_repo_id: RepoId,
    repo_topic: &mut RepoTopic,
    parent_topics: &Vec<ParentTopicRow>,
    children: &Vec<TopicChildRow>,
)

Source from the content-addressed store, hash-verified

199}
200
201fn persist_topic(
202 mutation: &mut Mutation,
203 repo_topic_repo_id: RepoId,
204 repo_topic: &mut RepoTopic,
205 parent_topics: &Vec<ParentTopicRow>,
206 children: &Vec<TopicChildRow>,
207) -> Result<()> {
208 let mut child_links = vec![];
209 let mut child_topics = vec![];
210
211 for child in children {
212 let TopicChildRow {
213 kind,
214 id,
215 repository_id,
216 name,
217 url,
218 ..
219 } = child;
220 let child_repo_id = RepoId::try_from(repository_id).unwrap();
221
222 if repo_topic_repo_id != child_repo_id {
223 continue;
224 }
225
226 match kind.as_str() {
227 "Topic" => {
228 let id = sha256_id(id);
229 child_topics.push(activity::TopicInfo::from((Locale::EN, name.to_owned(), id)));
230 }
231 "Link" => {
232 let id = sha256_id(url);
233 child_links.push(activity::LinkInfo {
234 title: name.to_owned(),
235 url: url.to_owned(),
236 id,
237 deleted: false,
238 });
239 }
240 _ => {}
241 };
242 }
243
244 let mut parents = vec![];
245 for topic in parent_topics {
246 let topic_repo_id = RepoId::try_from(&topic.repository_id).unwrap();
247 if topic_repo_id != repo_topic_repo_id {
248 continue;
249 }
250
251 let id = sha256_id(&topic.id);
252 parents.push(activity::TopicInfo::from((
253 Locale::EN,
254 topic.name.to_owned(),
255 id,
256 )));
257 }
258

Callers 1

persist_topicsFunction · 0.85

Calls 5

sha256_idFunction · 0.85
ImportTopicClass · 0.85
as_strMethod · 0.80
save_topicMethod · 0.80
add_changeMethod · 0.45

Tested by

no test coverage detected