Add: #198 contextのAPIについてwith_references対応 (#209)

This commit is contained in:
KMY(雪あすか) 2023-11-01 10:00:22 +09:00 committed by GitHub
parent cc938d76a7
commit 99511ee1b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 69 additions and 1 deletions

View file

@ -49,6 +49,11 @@ class Api::V1::StatusesController < Api::BaseController
loaded_descendants = cache_collection(descendants_results, Status)
loaded_references = cache_collection(references_results, Status)
unless params[:with_reference]
loaded_ancestors = (loaded_ancestors + loaded_references).uniq(&:id)
loaded_references = []
end
@context = Context.new(ancestors: loaded_ancestors, descendants: loaded_descendants, references: loaded_references)
statuses = [@status] + @context.ancestors + @context.descendants + @context.references