Merge branch 'develop' of https://git.trustie.net/Gitlink/forgeplus into develop

This commit is contained in:
jasder
2021-11-05 11:36:51 +08:00
55 changed files with 299 additions and 331 deletions

View File

@@ -20,7 +20,7 @@
</td>
<td><%= project_category.pinned_index == 0 ? "" : "√" %></td>
<td><%= project_category.projects_count %></td>
<td><%= project_category.projects.where(is_pinned: true).size %></td>
<td><%= project_category.projects.select(:id).where(is_pinned: true).size %></td>
<td><%= project_category.created_at&.strftime('%Y-%m-%d %H:%M') %></td>
<td class="action-container">
<%= link_to "编辑", edit_admins_project_category_path(project_category), remote: true, class: "action" %>

View File

@@ -12,10 +12,10 @@ json.array! @branches do |branch|
json.timestamp render_unix_time(branch['commit']['timestamp'])
json.time_from_now time_from_now(branch['commit']['timestamp'])
json.author do
json.partial! 'repositories/commit_author', user: render_commit_author(branch['commit']['author']), name: branch['commit']['author']['name']
json.partial! 'repositories/commit_author', user: render_cache_commit_author(branch['commit']['author']), name: branch['commit']['author']['name']
end
json.committer do
json.partial! 'repositories/commit_author', user: render_commit_author(branch['commit']['committer']), name: branch['commit']['committer']['name']
json.partial! 'repositories/commit_author', user: render_cache_commit_author(branch['commit']['committer']), name: branch['commit']['committer']['name']
end
end
end

View File

@@ -14,10 +14,10 @@ json.array! @branches_slice do |branch_slice|
json.timestamp render_unix_time(branch['commit']['timestamp'])
json.time_from_now time_from_now(branch['commit']['timestamp'])
json.author do
json.partial! 'repositories/commit_author', user: render_commit_author(branch['commit']['author']), name: branch['commit']['author']['name']
json.partial! 'repositories/commit_author', user: render_cache_commit_author(branch['commit']['author']), name: branch['commit']['author']['name']
end
json.committer do
json.partial! 'repositories/commit_author', user: render_commit_author(branch['commit']['committer']), name: branch['commit']['committer']['name']
json.partial! 'repositories/commit_author', user: render_cache_commit_author(branch['commit']['committer']), name: branch['commit']['committer']['name']
end
end
end

View File

@@ -1,11 +1,9 @@
json.author do
author = User.find_by(mail: commit['Author']['Email'])
json.partial! 'repositories/commit_author', locals: { user: author, name: commit['Committer']['Name'] }
json.partial! 'repositories/commit_author', locals: { user: render_cache_commit_author(commit['Author']), name: commit['Author']['Name'] }
end
json.committer do
author = User.find_by(mail: commit['Committer']['Email'])
json.partial! 'repositories/commit_author', locals: { user: author, name: commit['Committer']['Name'] }
json.partial! 'repositories/commit_author', locals: { user: render_cache_commit_author(commit['Committer']), name: commit['Committer']['Name'] }
end
json.timestamp render_unix_time(commit['Committer']['When'])
json.time_from_now time_from_now(commit['Committer']['When'])

View File

@@ -26,9 +26,9 @@ if @project.forge?
end
json.author do
json.partial! 'commit_author', user: render_commit_author(commit['commit']['author']), name: commit['commit']['author']['name']
json.partial! 'commit_author', user: render_cache_commit_author(commit['commit']['author']), name: commit['commit']['author']['name']
end
json.committer do
json.partial! 'commit_author', user: render_commit_author(commit['commit']['committer']), name: commit['commit']['committer']['name']
json.partial! 'commit_author', user: render_cache_commit_author(commit['commit']['committer']), name: commit['commit']['committer']['name']
end
end

View File

@@ -1,9 +1,17 @@
if user
json.id user.id
json.login user.login
json.name user.real_name
json.type user&.type
json.image_url url_to_avatar(user)
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

View File

@@ -0,0 +1,16 @@
user = $redis_cache.hgetall("v2-owner-common:#{contributor["login"]}-#{contributor["email"]}")
if user.blank?
json.contributions contributor["contributions"]
# json.gid contributor["id"]
json.login contributor["login"]
json.type nil
json.name contributor["login"]
json.image_url User::Avatar.get_letter_avatar_url(contributor["login"])
else
json.contributions contributor["contributions"]
# json.gid contributor["id"]
json.login user["login"]
json.type user["type"]
json.name user["name"]
json.image_url user["avatar_url"]
end

View File

@@ -28,10 +28,10 @@ else
# end
# end
json.author do
json.partial! 'commit_author', user: render_commit_author(commit['commit']['author']), name: commit['commit']['author']['name']
json.partial! 'commit_author', user: render_cache_commit_author(commit['commit']['author']), name: commit['commit']['author']['name']
end
json.committer do
json.partial! 'commit_author', user: render_commit_author(commit['commit']['committer']), name: commit['commit']['committer']['name']
json.partial! 'commit_author', user: render_cache_commit_author(commit['commit']['committer']), name: commit['commit']['committer']['name']
end
end
end

View File

@@ -1,16 +1,6 @@
total_count = @contributors.size
json.contributors @contributors.each do |contributor|
user = User.find_by(gitea_uid: contributor["id"])
if contributor["login"] == "root"
total_count -= 1
next
end
json.contributions contributor["contributions"]
# json.gid contributor["id"]
json.login user.login
json.type user&.type
json.name user.real_name
json.image_url url_to_avatar(user)
json.partial! 'contributor', locals: { contributor: contributor }
end
json.total_count total_count

View File

@@ -56,17 +56,7 @@ json.tags_count @result[:branch_tag_total_count]['tag_count'] || 0
json.contributors do
total_count = @result[:contributor].size
json.list @result[:contributor].each do |contributor|
user = User.find_by(gitea_uid: contributor["id"])
if contributor["login"] == "root" || user.nil?
total_count -= 1
next
end
json.contributions contributor["contributions"]
json.gid contributor["id"]
json.login user.login
json.type user&.type
json.name user.real_name
json.image_url url_to_avatar(user)
json.partial! 'contributor', locals: { contributor: contributor }
end
json.total_count total_count
end

View File

@@ -5,7 +5,7 @@ json.array! @tags do |tag|
json.zipball_url render_zip_url(@owner, @repository, tag['name'])
json.tarball_url render_tar_url(@owner, @repository, tag['name'])
json.tagger do
json.partial! 'commit_author', user: render_commit_author(tag['tagger']), name: tag['tagger']['name']
json.partial! 'commit_author', user: render_cache_commit_author(tag['tagger']), name: tag['tagger']['name']
end
json.time_ago time_from_now(tag['tagger']['date'].to_time)
json.created_at_unix tag['tagger']['date'].to_time.to_i
@@ -16,10 +16,10 @@ json.array! @tags do |tag|
json.time_ago time_from_now(tag['commit']['commiter']['date'].to_time)
json.created_at_unix tag['commit']['commiter']['date'].to_time.to_i
json.committer do
json.partial! 'commit_author', user: render_commit_author(tag['commit']['commiter']), name: tag['commit']['commiter']['name']
json.partial! 'commit_author', user: render_cache_commit_author(tag['commit']['commiter']), name: tag['commit']['commiter']['name']
end
json.author do
json.partial! 'commit_author', user: render_commit_author(tag['commit']['author']), name: tag['commit']['author']['name']
json.partial! 'commit_author', user: render_cache_commit_author(tag['commit']['author']), name: tag['commit']['author']['name']
end
end
end

View File

@@ -1,15 +1,21 @@
owner_common = $redis_cache.hgetall("v2-owner-common:#{item[0]}")
deleted_data = $redis_cache.smembers("v2-project-rank-deleted")
$redis_cache.zrem("v2-user-project-rank:#{item[0]}", delete_data) unless deleted_data.blank?
popular_project = $redis_cache.zrevrange("v2-user-project-rank:#{item[0]}", 0, 1, withscores: true)[0]
popular_project_common = $redis_cache.hgetall("v2-project-common:#{popular_project[0]}")
json.id item[0]
json.score item[1]
json.name owner_common["name"]
json.type owner_common["type"]
json.login owner_common["login"]
json.avatar_url owner_common["avatar_url"]
json.project do
json.id popular_project[0]
json.name popular_project_common["name"]
json.identifier popular_project_common["identifier"]
json.description popular_project_common["description"]
if popular_project.blank?
json.project nil
else
popular_project_common = $redis_cache.hgetall("v2-project-common:#{popular_project[0]}")
json.project do
json.id popular_project[0]
json.name popular_project_common["name"]
json.identifier popular_project_common["identifier"]
json.description popular_project_common["description"]
end
end