From 562044f36ad8ebe388e32eef2e5d44bec4a9af59 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 3 Nov 2016 13:59:31 +0100 Subject: [PATCH] Need to disable caching again due to bug in Rabl --- app/controllers/api/v1/statuses_controller.rb | 7 +++---- app/views/api/v1/accounts/relationship.rabl | 1 + app/views/api/v1/accounts/show.rabl | 2 +- app/views/api/v1/statuses/context.rabl | 15 ++++++--------- app/views/api/v1/statuses/show.rabl | 2 +- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index b02b7bb5723..3db4dbbd00e 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -9,10 +9,9 @@ class Api::V1::StatusesController < ApiController end def context - @status = Status.find(params[:id]) - @ancestors = @status.ancestors - @descendants = @status.descendants - set_maps([@status] + @ancestors + @descendants) + @status = Status.find(params[:id]) + @context = OpenStruct.new({ ancestors: @status.ancestors, descendants: @status.descendants }) + set_maps([@status] + @context[:ancestors] + @context[:descendants]) end def create diff --git a/app/views/api/v1/accounts/relationship.rabl b/app/views/api/v1/accounts/relationship.rabl index 3e5bf882c1a..4f634877f73 100644 --- a/app/views/api/v1/accounts/relationship.rabl +++ b/app/views/api/v1/accounts/relationship.rabl @@ -1,4 +1,5 @@ object @account +cache false attribute :id node(:following) { |account| @following[account.id] || false } node(:followed_by) { |account| @followed_by[account.id] || false } diff --git a/app/views/api/v1/accounts/show.rabl b/app/views/api/v1/accounts/show.rabl index 08199ec215a..6aec6e14dea 100644 --- a/app/views/api/v1/accounts/show.rabl +++ b/app/views/api/v1/accounts/show.rabl @@ -1,5 +1,5 @@ object @account -cache @account +cache false attributes :id, :username, :acct, :display_name, :note diff --git a/app/views/api/v1/statuses/context.rabl b/app/views/api/v1/statuses/context.rabl index e9176dc29ff..24fa4039484 100644 --- a/app/views/api/v1/statuses/context.rabl +++ b/app/views/api/v1/statuses/context.rabl @@ -1,13 +1,10 @@ -object false +object @context +cache false -node :ancestors do - @ancestors.map do |status| - partial('api/v1/statuses/show', object: status) - end +node :ancestors do |context| + partial 'api/v1/statuses/index', object: context.ancestors end -node :descendants do - @descendants.map do |status| - partial('api/v1/statuses/show', object: status) - end +node :descendants do |context| + partial 'api/v1/statuses/index', object: context.descendants end diff --git a/app/views/api/v1/statuses/show.rabl b/app/views/api/v1/statuses/show.rabl index f78716e1b9e..24493bc3eba 100644 --- a/app/views/api/v1/statuses/show.rabl +++ b/app/views/api/v1/statuses/show.rabl @@ -1,5 +1,5 @@ object @status -cache @status +cache false extends 'api/v1/statuses/_show'