From bea6442a1c7febed609e8db87d3361e163770ee3 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 18 May 2023 09:19:45 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fixed=20=E6=8F=90=E4=BA=A4=E8=80=85?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E7=94=A8=E6=88=B7email?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/repositories_helper.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index c9be515d2..0f3f27ac0 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -36,12 +36,20 @@ module RepositoriesHelper end def render_cache_commit_author(author_json) + user = nil if author_json["name"].present? && author_json["email"].present? - return find_user_in_redis_cache(author_json['name'], author_json['email']) + user = find_user_in_redis_cache(author_json['name'], author_json['email']) end if author_json["Name"].present? && author_json["Email"].present? - return find_user_in_redis_cache(author_json['Name'], author_json['Email']) + user = find_user_in_redis_cache(author_json['Name'], author_json['Email']) end + if user.blank? && author_json["email"].present? + user = User.find_by(mail: author_json["email"]) + end + if user.blank? && author_json["Email"].present? + user = User.find_by(mail: author_json["Email"]) + end + user end def readme_render_decode64_content(str, owner, repo, ref, path) From ee62c394fca270d8dbd7ee76578b1fe6d5d98177 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 18 May 2023 09:32:36 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fixed=20=E5=AE=A1=E6=89=B9utf8mb4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230518012718_add_forge_applied_message_utf8mb4.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/migrate/20230518012718_add_forge_applied_message_utf8mb4.rb diff --git a/db/migrate/20230518012718_add_forge_applied_message_utf8mb4.rb b/db/migrate/20230518012718_add_forge_applied_message_utf8mb4.rb new file mode 100644 index 000000000..a12fbd291 --- /dev/null +++ b/db/migrate/20230518012718_add_forge_applied_message_utf8mb4.rb @@ -0,0 +1,5 @@ +class AddForgeAppliedMessageUtf8mb4 < ActiveRecord::Migration[5.2] + def change + execute("ALTER TABLE `forge_applied_messages` MODIFY `name` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;") + end +end From 2aeaee847962921326f7674d037be0a804e2d8f7 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 18 May 2023 10:21:32 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fixed=20=E9=A1=B9=E7=9B=AE=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=EF=BC=8C=E6=A0=87=E8=AF=86=EF=BC=8C=E6=89=80=E6=9C=89?= =?UTF-8?q?=E8=80=85=E5=8F=98=E5=8C=96=E6=97=B6=E9=87=8D=E7=BD=AE=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 6e7d258aa..192288019 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -238,6 +238,13 @@ class ProjectsController < ApplicationController def simple # 为了缓存活跃项目的基本信息,后续删除 Cache::V2::ProjectCommonService.new(@project.id).read + # 项目名称,标识,所有者变化时重置缓存 + project_common = $redis_cache.hgetall("v2-project-common:#{@project.id}") + if project_common.present? + if project_common["name"] != @project.name || project_common["identifier"] != @project.identifier || project_common["owner_id"] != @project.user_id + Cache::V2::ProjectCommonService.new(@project.id).reset + end + end json_response(@project, current_user) end From 09b1007800391eb2f29e859f7fb93a6bdf272d4d Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 18 May 2023 14:22:53 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fixed=20=E8=B4=A1=E7=8C=AE=E8=80=85?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E7=94=A8=E6=88=B7email?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repositories/_contributor.json.jbuilder | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/app/views/repositories/_contributor.json.jbuilder b/app/views/repositories/_contributor.json.jbuilder index b0547eba3..2deab09d2 100644 --- a/app/views/repositories/_contributor.json.jbuilder +++ b/app/views/repositories/_contributor.json.jbuilder @@ -1,20 +1,33 @@ -user = $redis_cache.hgetall("v2-owner-common:#{contributor["name"] || contributor["login"]}-#{contributor["email"]}") -if user.blank? +user = render_cache_commit_author(contributor) +if user.present? + if user.is_a?(Hash) + json.contributions contributor["commits"] || contributor["contributions"] + json.id user["id"] + json.login user["login"] + json.email user["email"] + json.type user["type"] + json.name (user["name"] || contributor["name"] || contributor["login"]).to_s.downcase + json.image_url user["avatar_url"] + db_user = User.find_by_id(user["id"]) + json.contribution_perc db_user.simple_contribution_perc(project, contributor["contribution_perc"]) if db_user.present? + else + json.contributions contributor["commits"] || contributor["contributions"] + json.id user.id + json.login user.login + json.email user.mail + json.type user.type + json.name user.real_name + json.image_url url_to_avatar(user) + json.contribution_perc user.simple_contribution_perc(project, contributor["contribution_perc"]) if user.present? + end +else json.contributions contributor["commits"] || contributor["contributions"] + json.id nil json.login nil json.type nil json.name (contributor["name"] || contributor["login"]).to_s.downcase json.email contributor["email"] json.image_url User::Avatar.get_letter_avatar_url(contributor["name"] || contributor["login"]) json.contribution_perc User.new(login: (contributor["name"] || contributor["login"]), mail: contributor["email"]).simple_contribution_perc(project, contributor["contribution_perc"]) -else - json.contributions contributor["commits"] || contributor["contributions"] - json.id user["id"] - json.login user["login"] - json.email user["email"] - json.type user["type"] - json.name (user["name"] || contributor["name"] || contributor["login"]).to_s.downcase - json.image_url user["avatar_url"] - db_user = User.find_by_id(user["id"]) - json.contribution_perc db_user.simple_contribution_perc(project, contributor["contribution_perc"]) if db_user.present? end + From 8fbf1b4a35d40222f5efb9cb3c22680b1faae289 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 18 May 2023 14:26:38 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fixed=20=E8=B4=A1=E7=8C=AE=E8=80=85?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E7=94=A8=E6=88=B7email=EF=BC=8C=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=8C=BA=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/_contributor.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/repositories/_contributor.json.jbuilder b/app/views/repositories/_contributor.json.jbuilder index 2deab09d2..861efb8bb 100644 --- a/app/views/repositories/_contributor.json.jbuilder +++ b/app/views/repositories/_contributor.json.jbuilder @@ -16,7 +16,7 @@ if user.present? json.login user.login json.email user.mail json.type user.type - json.name user.real_name + json.name (user["name"] || contributor["name"] || contributor["login"]).to_s.downcase json.image_url url_to_avatar(user) json.contribution_perc user.simple_contribution_perc(project, contributor["contribution_perc"]) if user.present? end