|
|
|
@@ -37,19 +37,22 @@ class Admins::ProjectsRankController < Admins::BaseController |
|
|
|
def export_excel(data) |
|
|
|
book = Spreadsheet::Workbook.new |
|
|
|
sheet = book.create_worksheet :name => "项目活跃度排行" |
|
|
|
sheet.row(0).concat %w(排名 项目全称 项目地址 得分 访问数 关注数 点赞数 fork数 疑修数 合并请求数 提交数) |
|
|
|
sheet.row(0).concat %w(排名 项目全称 项目地址 项目分类 首次创建时间 外部迁移/独立创建 得分 访问数 关注数 点赞数 fork数 疑修数 合并请求数 提交数) |
|
|
|
data.each_with_index do |d, index| |
|
|
|
sheet[index+1,0] = index+1 |
|
|
|
sheet[index+1,1] = "#{d&.project&.owner&.real_name}/#{d&.project&.name}" |
|
|
|
sheet[index+1,2] = "#{Rails.application.config_for(:configuration)['platform_url']}/#{d&.project&.owner&.login}/#{d&.project&.identifier}" |
|
|
|
sheet[index+1,3] = d.score |
|
|
|
sheet[index+1,4] = d.visits |
|
|
|
sheet[index+1,5] = d.watchers |
|
|
|
sheet[index+1,6] = d.praises |
|
|
|
sheet[index+1,7] = d.forks |
|
|
|
sheet[index+1,8] = d.issues |
|
|
|
sheet[index+1,9] = d.pullrequests |
|
|
|
sheet[index+1,10] = d.commits |
|
|
|
sheet[index+1,4] = d&.project&.project_category&.name |
|
|
|
sheet[index+1,5] = d&.project&.created_on |
|
|
|
sheet[index+1,6] = d&.project&.common? ? "独立创建" : "外部迁移" |
|
|
|
sheet[index+1,7] = d.visits |
|
|
|
sheet[index+1,8] = d.watchers |
|
|
|
sheet[index+1,9] = d.praises |
|
|
|
sheet[index+1,10] = d.forks |
|
|
|
sheet[index+1,11] = d.issues |
|
|
|
sheet[index+1,12] = d.pullrequests |
|
|
|
sheet[index+1,13] = d.commits |
|
|
|
end |
|
|
|
book.write "#{Rails.root}/public/项目活跃度排行.xls" |
|
|
|
end |
|
|
|
|