Method: Graphql::Dashboard::OperationStore::OperationsController#index

Defined in:
lib/graphql/dashboard/operation_store.rb

#indexObject



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/graphql/dashboard/operation_store.rb', line 82

def index
  @client_operations = client_name = params[:client_name]
  per_page = params[:per_page]&.to_i || 25
  page = params[:page]&.to_i || 1
  @is_archived = params[:archived_status] == :archived
  order_by = params[:order_by] || "name"
  order_dir = params[:order_dir]&.to_sym || :asc
  if @client_operations
    @operations_page = schema_class.operation_store.get_client_operations_by_client(
      client_name,
      page: page,
      per_page: per_page,
      is_archived: @is_archived,
      order_by: order_by,
      order_dir: order_dir,
    )
    opposite_archive_mode_count = schema_class.operation_store.get_client_operations_by_client(
      client_name,
      page: 1,
      per_page: 1,
      is_archived: !@is_archived,
      order_by: order_by,
      order_dir: order_dir,
    ).total_count
  else
    @operations_page = schema_class.operation_store.all_operations(
      page: page,
      per_page: per_page,
      is_archived: @is_archived,
      order_by: order_by,
      order_dir: order_dir,
    )
    opposite_archive_mode_count = schema_class.operation_store.all_operations(
      page: 1,
      per_page: 1,
      is_archived: !@is_archived,
      order_by: order_by,
      order_dir: order_dir,
    ).total_count
  end

  if @is_archived
    @archived_operations_count = @operations_page.total_count
    @unarchived_operations_count = opposite_archive_mode_count
  else
    @archived_operations_count = opposite_archive_mode_count
    @unarchived_operations_count = @operations_page.total_count
  end
end