graphs_controller.rb 732 字节
Newer Older
1
class Projects::GraphsController < Projects::ApplicationController
2 3 4 5
  # Authorize
  before_filter :authorize_read_project!
  before_filter :authorize_code_access!
  before_filter :require_non_empty_project
6

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

  private

  def fetch_graph
D
Dmitriy Zaporozhets 已提交
19
    @commits = @project.repository.commits(nil, nil, 6000, 0, true)
D
Dmitriy Zaporozhets 已提交
20
    @log = []
D
Dmitriy Zaporozhets 已提交
21 22 23 24 25 26 27 28 29 30

    @commits.each do |commit|
      @log << {
        author_name: commit.author_name.force_encoding('UTF-8'),
        author_email: commit.author_email.force_encoding('UTF-8'),
        date: commit.committed_date.strftime("%Y-%m-%d")
      }
    end

    render json: @log.to_json
D
Dmitriy Zaporozhets 已提交
31
  end
32
end