From 38fc1b498d971f7b33532c583b12e5dd3469af3c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 29 Dec 2017 19:52:04 +0100 Subject: Add more instance stats APIs (#6125) * Add GET /api/v1/instance/peers API to reveal known domains * Add GET /api/v1/instance/activity API * Make new APIs disableable, exclude private statuses from activity stats * Fix code style issue * Fix week timestamps --- app/controllers/application_controller.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a213302cb..51a978f44 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -121,4 +121,13 @@ class ApplicationController < ActionController::Base end end end + + def render_cached_json(cache_key, **options) + data = Rails.cache.fetch(cache_key, { raw: true }.merge(options)) do + yield.to_json + end + + expires_in options[:expires_in], public: true + render json: data + end end -- cgit