add: repo commit user use cache data
This commit is contained in:
parent
46405e704a
commit
28c3b4dda4
|
@ -442,6 +442,14 @@ module ApplicationHelper
|
||||||
User.find_by(gitea_uid: gitea_uid)
|
User.find_by(gitea_uid: gitea_uid)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_user_in_redis_cache(login, email)
|
||||||
|
$redis_cache.hgetall("v2-owner-common:#{login}-#{email}")
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_user_in_redis_cache_by_id(id)
|
||||||
|
$redis_cache.hgetall("v2-owner-common:#{id}")
|
||||||
|
end
|
||||||
|
|
||||||
def render_base64_decoded(str)
|
def render_base64_decoded(str)
|
||||||
return nil if str.blank?
|
return nil if str.blank?
|
||||||
Base64.decode64 str
|
Base64.decode64 str
|
||||||
|
|
|
@ -35,6 +35,10 @@ module RepositoriesHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render_cache_commit_author(author_json)
|
||||||
|
find_user_in_redis_cache(author_json['name'], author_json['email'])
|
||||||
|
end
|
||||||
|
|
||||||
def readme_render_decode64_content(str, path)
|
def readme_render_decode64_content(str, path)
|
||||||
return nil if str.blank?
|
return nil if str.blank?
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -12,10 +12,10 @@ json.array! @branches do |branch|
|
||||||
json.timestamp render_unix_time(branch['commit']['timestamp'])
|
json.timestamp render_unix_time(branch['commit']['timestamp'])
|
||||||
json.time_from_now time_from_now(branch['commit']['timestamp'])
|
json.time_from_now time_from_now(branch['commit']['timestamp'])
|
||||||
json.author do
|
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
|
end
|
||||||
json.committer do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,10 +14,10 @@ json.array! @branches_slice do |branch_slice|
|
||||||
json.timestamp render_unix_time(branch['commit']['timestamp'])
|
json.timestamp render_unix_time(branch['commit']['timestamp'])
|
||||||
json.time_from_now time_from_now(branch['commit']['timestamp'])
|
json.time_from_now time_from_now(branch['commit']['timestamp'])
|
||||||
json.author do
|
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
|
end
|
||||||
json.committer do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
json.author do
|
json.author do
|
||||||
author = User.find_by(mail: commit['Author']['Email'])
|
json.partial! 'repositories/commit_author', locals: { user: render_cache_commit_author(commit['Author']), name: commit['Author']['Name'] }
|
||||||
json.partial! 'repositories/commit_author', locals: { user: author, name: commit['Committer']['Name'] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
json.committer do
|
json.committer do
|
||||||
author = User.find_by(mail: commit['Committer']['Email'])
|
json.partial! 'repositories/commit_author', locals: { user: render_cache_commit_author(commit['Committer']), name: commit['Committer']['Name'] }
|
||||||
json.partial! 'repositories/commit_author', locals: { user: author, name: commit['Committer']['Name'] }
|
|
||||||
end
|
end
|
||||||
json.timestamp render_unix_time(commit['Committer']['When'])
|
json.timestamp render_unix_time(commit['Committer']['When'])
|
||||||
json.time_from_now time_from_now(commit['Committer']['When'])
|
json.time_from_now time_from_now(commit['Committer']['When'])
|
||||||
|
|
|
@ -26,9 +26,9 @@ if @project.forge?
|
||||||
end
|
end
|
||||||
|
|
||||||
json.author do
|
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
|
end
|
||||||
json.committer do
|
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
|
end
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
if user
|
if user.present?
|
||||||
json.id user.id
|
if user.is_a?(Hash)
|
||||||
json.login user.login
|
json.id user["id"]
|
||||||
json.name user.real_name
|
json.login user["login"]
|
||||||
json.type user&.type
|
json.name user["name"]
|
||||||
json.image_url url_to_avatar(user)
|
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
|
else
|
||||||
json.id nil
|
json.id nil
|
||||||
json.login name
|
json.login name
|
||||||
|
|
|
@ -28,10 +28,10 @@ else
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
json.author do
|
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
|
end
|
||||||
json.committer do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ json.array! @tags do |tag|
|
||||||
json.zipball_url render_zip_url(@owner, @repository, tag['name'])
|
json.zipball_url render_zip_url(@owner, @repository, tag['name'])
|
||||||
json.tarball_url render_tar_url(@owner, @repository, tag['name'])
|
json.tarball_url render_tar_url(@owner, @repository, tag['name'])
|
||||||
json.tagger do
|
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
|
end
|
||||||
json.time_ago time_from_now(tag['tagger']['date'].to_time)
|
json.time_ago time_from_now(tag['tagger']['date'].to_time)
|
||||||
json.created_at_unix tag['tagger']['date'].to_time.to_i
|
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.time_ago time_from_now(tag['commit']['commiter']['date'].to_time)
|
||||||
json.created_at_unix tag['commit']['commiter']['date'].to_time.to_i
|
json.created_at_unix tag['commit']['commiter']['date'].to_time.to_i
|
||||||
json.committer do
|
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
|
end
|
||||||
json.author do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue