mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-24 13:45:44 +08:00
[ADD]统计平台概况
[FIX]更改请求参数 [FIX] [ADD]rank statistic [FIX]
This commit is contained in:
34
app/queries/statistic/active_project_rank_query.rb
Normal file
34
app/queries/statistic/active_project_rank_query.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
class Statistic::ActiveProjectRankQuery < ApplicationQuery
|
||||
attr_reader :params, :user
|
||||
|
||||
def initialize(params, user)
|
||||
@params = params
|
||||
@user = user
|
||||
end
|
||||
|
||||
def call
|
||||
begin
|
||||
result = Gitea::Activity::ProjectService.call(start_time, end_time, top, user.gitea_token)
|
||||
|
||||
return result["project"]
|
||||
rescue
|
||||
return []
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def start_time
|
||||
params.fetch(:start_time, Time.now.beginning_of_day.to_i).to_i
|
||||
end
|
||||
|
||||
def end_time
|
||||
params.fetch(:end_time, Time.now.to_i).to_i
|
||||
end
|
||||
|
||||
def top
|
||||
top = params.fetch(:top, 5).to_i
|
||||
top = top >= 20 ? 20 : top
|
||||
top = top <= 0 ? 5 : top
|
||||
top
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user