diff --git a/Gemfile b/Gemfile index 009eda921..e37371108 100644 --- a/Gemfile +++ b/Gemfile @@ -139,4 +139,4 @@ gem 'doorkeeper' gem 'doorkeeper-jwt' -gem 'gitea-client', '~> 0.10.6' \ No newline at end of file +gem 'gitea-client', '~> 0.11.1' \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b88849f56..7490cb27f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -665,7 +665,7 @@ class ApplicationController < ActionController::Base def kaminari_paginate(relation) limit = params[:limit] || params[:per_page] - limit = (limit.to_i.zero? || limit.to_i > 25) ? 25 : limit.to_i + limit = (limit.to_i.zero? || limit.to_i > 50) ? 50 : limit.to_i page = params[:page].to_i.zero? ? 1 : params[:page].to_i relation.page(page).per(limit) diff --git a/app/controllers/project_rank_controller.rb b/app/controllers/project_rank_controller.rb index 7bd62987e..5cea074fb 100644 --- a/app/controllers/project_rank_controller.rb +++ b/app/controllers/project_rank_controller.rb @@ -1,10 +1,10 @@ class ProjectRankController < ApplicationController # 根据时间获取热门项目 def index - $redis_cache.zunionstore("recent-days-project-rank", get_timeable_key_names) + $redis_cache.zunionstore("recent-days-project-rank-#{time}", get_timeable_key_names) deleted_data = $redis_cache.smembers("v2-project-rank-deleted") - $redis_cache.zrem("recent-days-project-rank", deleted_data) unless deleted_data.blank? - @project_rank = $redis_cache.zrevrange("recent-days-project-rank", 0, 4, withscores: true) + $redis_cache.zrem("recent-days-project-rank-#{time}", deleted_data) unless deleted_data.blank? + @project_rank = $redis_cache.zrevrange("recent-days-project-rank-#{time}", 0, 9, withscores: true) rescue Exception => e @project_rank = [] end diff --git a/app/models/project.rb b/app/models/project.rb index 6ce31522c..a8816bd76 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -175,6 +175,9 @@ class Project < ApplicationRecord $redis_cache.srem("v2-project-rank-deleted", self.id) end end + if !self.common? + CacheAsyncClearJob.perform_later('project_rank_service', self.id) + end end def decre_project_common diff --git a/app/views/api/v1/projects/code_stats/index.json.jbuilder b/app/views/api/v1/projects/code_stats/index.json.jbuilder index d438e2624..0b64270f7 100644 --- a/app/views/api/v1/projects/code_stats/index.json.jbuilder +++ b/app/views/api/v1/projects/code_stats/index.json.jbuilder @@ -6,7 +6,7 @@ json.deletions @result_object["deletions"] json.commit_count_in_all_branches @result_object["commit_count_in_all_branches"] json.authors @result_object["authors"].each do |author| json.author do - json.partial! 'api/v1/users/commit_user', locals: { user: render_cache_commit_author(author), name: author['name'] } + json.partial! 'api/v1/users/commit_user_email', locals: { user: render_cache_commit_author(author), name: author['name'], email: author['email'] } end json.commits author["commits"] json.additions author["additions"] diff --git a/app/views/api/v1/users/_commit_user_email.json.jbuilder b/app/views/api/v1/users/_commit_user_email.json.jbuilder new file mode 100644 index 000000000..c4963628a --- /dev/null +++ b/app/views/api/v1/users/_commit_user_email.json.jbuilder @@ -0,0 +1,22 @@ +if user.present? + if user.is_a?(Hash) + json.id user["id"] + json.login user["login"] + json.name user["name"] + json.type user["type"] + json.image_url user["avatar_url"] + else + json.id user.id + json.login user.login + json.name user.real_name + json.type user&.type + json.image_url url_to_avatar(user) + end +else + json.id nil + json.login name + json.name name + json.email email + json.type nil + json.image_url User::Avatar.get_letter_avatar_url(name) +end