move PlannerController#index onto slave

refs ADMIN-1342

Change-Id: Icba9567614865df2e4e3a9b2e19c6053eccb0526
Reviewed-on: https://gerrit.instructure.com/160968
Tested-by: Jenkins
Reviewed-by: Dan Minkevitch <dan@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Jeremy Stanley 2018-08-15 15:44:09 -06:00 committed by Cody Cutrer
parent d99d409780
commit 91820598a9
1 changed files with 24 additions and 22 deletions

View File

@ -120,29 +120,31 @@ class PlannerController < ApplicationController
# }
# ]
def index
# fetch a meta key so we can invalidate just this info and not the whole of the user's cache
planner_overrides_meta_key = Rails.cache.fetch(planner_meta_cache_key, expires_in: 120.minutes) do
SecureRandom.uuid
Shackles.activate(:slave) do
# fetch a meta key so we can invalidate just this info and not the whole of the user's cache
planner_overrides_meta_key = Rails.cache.fetch(planner_meta_cache_key, expires_in: 120.minutes) do
SecureRandom.uuid
end
composite_cache_key = ['planner_items',
planner_overrides_meta_key,
page,
params[:filter],
default_opts,
contexts_cache_key].cache_key
items_response = Rails.cache.fetch(composite_cache_key, expires_in: 120.minutes) do
items = collection_for_filter(params[:filter])
items = Api.paginate(items, self, api_v1_planner_items_url)
{
json: planner_items_json(items, @current_user, session, {due_after: start_date, due_before: end_date}),
link: response.headers["Link"].to_s,
}
end
response.headers["Link"] = items_response[:link]
render json: items_response[:json]
end
composite_cache_key = ['planner_items',
planner_overrides_meta_key,
page,
params[:filter],
default_opts,
contexts_cache_key].cache_key
items_response = Rails.cache.fetch(composite_cache_key, expires_in: 120.minutes) do
items = collection_for_filter(params[:filter])
items = Api.paginate(items, self, api_v1_planner_items_url)
{
json: planner_items_json(items, @current_user, session, {due_after: start_date, due_before: end_date}),
link: response.headers["Link"].to_s,
}
end
response.headers["Link"] = items_response[:link]
render json: items_response[:json]
end
private