This commit is contained in:
2026-05-01 04:43:30 +09:00
parent a7020fb129
commit fa8eb66535
9 changed files with 128 additions and 24 deletions
+13 -5
View File
@@ -37,18 +37,26 @@ class Post < ApplicationRecord
def parent_posts = parents
def child_posts = children
def sibling_posts
parent_post_ids = parent_posts.order(:id).pluck(:id)
parent_post_ids.to_h { [_1, PostImplication.where(parent_post: _1).map(&:post)] }
end
def as_json options = { }
super(options).merge({ thumbnail: thumbnail.attached? ?
Rails.application.routes.url_helpers.rails_blob_url(
thumbnail, only_path: false) :
nil })
super(options).merge(thumbnail: thumbnail.attached? ?
Rails.application.routes.url_helpers.rails_blob_url(
thumbnail, only_path: false) :
nil)
rescue
super(options).merge(thumbnail: nil)
end
def snapshot_tag_names = tags.joins(:tag_name).order('tag_names.name').pluck('tag_names.name')
def snapshot_parent_post_ids = parents.order(:parent_post_id).pulck(:parent_post_id)
def snapshot_parent_post_ids = parents.order(:parent_post_id).pluck(:parent_post_id)
def related limit: nil
ids = post_similarities.order(cos: :desc)