2024-12-07 17:30:25 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
module ::DiscourseRewind
|
|
|
|
|
class RewindsController < ::ApplicationController
|
|
|
|
|
requires_plugin PLUGIN_NAME
|
|
|
|
|
|
2025-01-13 18:17:02 +01:00
|
|
|
requires_login
|
|
|
|
|
|
2024-12-07 17:30:25 +01:00
|
|
|
def show
|
2025-01-20 16:50:51 +01:00
|
|
|
DiscourseRewind::FetchReports.call(service_params) do
|
2025-11-19 09:36:08 +10:00
|
|
|
on_model_not_found(:year) do
|
|
|
|
|
raise Discourse::NotFound.new(nil, custom_message: "discourse_rewind.invalid_year")
|
|
|
|
|
end
|
|
|
|
|
on_model_not_found(:reports) do
|
|
|
|
|
raise Discourse::NotFound.new(nil, custom_message: "discourse_rewind.report_failed")
|
|
|
|
|
end
|
2025-11-18 09:03:41 -05:00
|
|
|
on_success { |reports:| render json: MultiJson.dump(reports), status: :ok }
|
2024-12-07 18:40:23 +01:00
|
|
|
end
|
2024-12-07 17:30:25 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|