From ebb0b45299cd3d419d8ffed9b7663f371ba93ddb Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Thu, 25 Feb 2021 11:03:32 +0900 Subject: [PATCH] Create blog_authors only when needed --- plume-models/src/posts.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index de2d123e..21470cb2 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -706,17 +706,20 @@ impl FromId for Post { cover_id: cover, }, ) - })?; + .and_then(|post| { + for author in authors { + PostAuthor::insert( + conn, + NewPostAuthor { + post_id: post.id, + author_id: author.id, + }, + )?; + } - for author in authors { - PostAuthor::insert( - conn, - NewPostAuthor { - post_id: post.id, - author_id: author.id, - }, - )?; - } + Ok(post) + }) + })?; // save mentions and tags let mut hashtags = md_to_html(&post.source, None, false, None)