Class: Projects::GraphsController

Inherits:
ApplicationController show all
Includes:
ExtractsPath
Defined in:
app/controllers/projects/graphs_controller.rb

Instance Method Summary collapse

Methods included from ExtractsPath

#assign_ref_vars, #extract_ref, #tree

Methods inherited from ApplicationController

#redirect_back_or_default

Methods included from PageLayoutHelper

#blank_container, #container_class, #fluid_layout, #header_title, #nav, #page_card_attributes, #page_card_meta_tags, #page_description, #page_image, #page_title, #sidebar

Methods included from GitlabRoutingHelper

#activity_project_path, #edit_project_path, #edit_project_url, #issue_path, #issue_url, #merge_request_path, #merge_request_url, #milestone_path, #project_builds_path, #project_commits_path, #project_files_path, #project_path, #project_pipelines_path, #project_snippet_url, #project_url, #runner_path, #runners_path, #toggle_subscription_path

Methods included from Gitlab::GonHelper

#add_gon_variables

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Projects::ApplicationController

Instance Method Details

#ciObject


27
28
29
30
31
32
33
# File 'app/controllers/projects/graphs_controller.rb', line 27

def ci
  @charts = {}
  @charts[:week] = Ci::Charts::WeekChart.new(project)
  @charts[:month] = Ci::Charts::MonthChart.new(project)
  @charts[:year] = Ci::Charts::YearChart.new(project)
  @charts[:build_times] = Ci::Charts::BuildTime.new(project)
end

#commitsObject


19
20
21
22
23
24
25
# File 'app/controllers/projects/graphs_controller.rb', line 19

def commits
  @commits = @project.repository.commits(@ref, limit: 2000, skip_merges: true)
  @commits_graph = Gitlab::Graphs::Commits.new(@commits)
  @commits_per_week_days = @commits_graph.commits_per_week_days
  @commits_per_time = @commits_graph.commits_per_time
  @commits_per_month = @commits_graph.commits_per_month
end

#languagesObject


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/projects/graphs_controller.rb', line 35

def languages
  @languages = Linguist::Repository.new(@repository.rugged, @repository.rugged.head.target_id).languages
  total = @languages.map(&:last).sum

  @languages = @languages.map do |language|
    name, share = language
    color = Digest::SHA256.hexdigest(name)[0...6]
    {
      value: (share.to_f * 100 / total).round(2),
      label: name,
      color: "##{color}",
      highlight: "##{color}"
    }
  end

  @languages.sort! do |x, y|
    y[:value] <=> x[:value]
  end
end

#showObject


10
11
12
13
14
15
16
17
# File 'app/controllers/projects/graphs_controller.rb', line 10

def show
  respond_to do |format|
    format.html
    format.json do
      fetch_graph
    end
  end
end