Class: Hubstats::BaseController

Inherits:
ApplicationController show all
Defined in:
app/controllers/hubstats/base_controller.rb

Instance Method Summary collapse

Instance Method Details

#grouping(group_request, group) ⇒ Object

Public - If the group is being asked to be grouped by user or repo, will make an array and group the data by either username or repo name.

group_request - string of what the data should be grouped by group - the group of data to be grouped

Returns - nothing



13
14
15
16
17
18
19
# File 'app/controllers/hubstats/base_controller.rb', line 13

def grouping (group_request, group)
  if group_request == "user"
    @groups = group.to_a.group_by(&:user_name)
  elsif group_request == "repo"
    @groups = group.to_a.group_by(&:repo_name)
  end
end