“6bac0e2235847a3932dbdd342d68da336277dde6”上不存在“src/vs/git@gitcode.net:xxadev/vscode.git”
graphs_controller.rb 1.0 KB
Newer Older
1
class Projects::GraphsController < Projects::ApplicationController
2 3
  include ExtractsPath

4
  # Authorize
5
  before_action :require_non_empty_project
6
  before_action :assign_ref_vars
7
  before_action :authorize_download_code!
8

9
  def show
10 11
    respond_to do |format|
      format.html
D
Dmitriy Zaporozhets 已提交
12
      format.json do
D
Dmitriy Zaporozhets 已提交
13
        fetch_graph
14 15
      end
    end
16
  end
D
Dmitriy Zaporozhets 已提交
17

18
  def commits
19
    @commits = @project.repository.commits(@ref, nil, 2000, 0, true)
D
Dmitriy Zaporozhets 已提交
20 21 22 23
    @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
24 25
  end

D
Dmitriy Zaporozhets 已提交
26 27 28
  private

  def fetch_graph
29
    @commits = @project.repository.commits(@ref, nil, 6000, 0, true)
D
Dmitriy Zaporozhets 已提交
30
    @log = []
D
Dmitriy Zaporozhets 已提交
31 32 33

    @commits.each do |commit|
      @log << {
34 35
        author_name: commit.author_name,
        author_email: commit.author_email,
D
Dmitriy Zaporozhets 已提交
36 37 38 39 40
        date: commit.committed_date.strftime("%Y-%m-%d")
      }
    end

    render json: @log.to_json
D
Dmitriy Zaporozhets 已提交
41
  end
42
end