Class: Graphql::Dashboard::Subscriptions::TopicsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- ApplicationController
- BaseController
- Graphql::Dashboard::Subscriptions::TopicsController
- Defined in:
- lib/graphql/dashboard/subscriptions.rb
Constant Summary
Constants inherited from BaseController
BaseController::INSTALLABLE_COMPONENT_HEADER_HTML, BaseController::INSTALLABLE_COMPONENT_MESSAGE_HTML
Instance Method Summary collapse
Methods inherited from BaseController
Methods included from Installable
#check_installed, #feature_installed?
Methods inherited from ApplicationController
Instance Method Details
#index ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/graphql/dashboard/subscriptions.rb', line 53 def index page = params[:page]&.to_i || 1 per_page = params[:per_page]&.to_i || 20 offset = per_page * (page - 1) limit = per_page topics, all_topics_count, has_next_page = schema_class.subscriptions.topics(offset: offset, limit: limit) @topics = topics @all_topics_count = all_topics_count @has_next_page = has_next_page @page = page end |
#show ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/graphql/dashboard/subscriptions.rb', line 22 def show topic_name = params[:name] all_subscription_ids = [] schema_class.subscriptions.each_subscription_id(topic_name) do |sid| all_subscription_ids << sid end page = params[:page]&.to_i || 1 limit = params[:per_page]&.to_i || 20 offset = limit * (page - 1) subscription_ids = all_subscription_ids[offset, limit] subs = schema_class.subscriptions.read_subscriptions(subscription_ids) show_broadcast_subscribers_count = schema_class.subscriptions.show_broadcast_subscribers_count? subs.each do |sub| sub[:is_broadcast] = is_broadcast = schema_class.subscriptions.broadcast_subscription_id?(sub[:id]) if is_broadcast && show_broadcast_subscribers_count sub[:subscribers_count] = sub_count =schema_class.subscriptions.count_broadcast_subscribed(sub[:id]) sub[:still_subscribed] = sub_count > 0 else sub[:still_subscribed] = schema_class.subscriptions.still_subscribed?(sub[:id]) sub[:subscribers_count] = nil end end @topic_last_triggered_at = schema_class.subscriptions.topic_last_triggered_at(topic_name) @subscriptions = subs @subscriptions_count = all_subscription_ids.size @show_broadcast_subscribers_count = show_broadcast_subscribers_count @has_next_page = all_subscription_ids.size > offset + limit ? page + 1 : false end |