From 2ca77732c88ff95fc077bfc46410204478ab40fa Mon Sep 17 00:00:00 2001 From: xiaoxiaoqiong Date: Fri, 21 Jan 2022 15:50:37 +0800 Subject: [PATCH 1/8] =?UTF-8?q?fixed=20=E6=B3=A8=E5=86=8C=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/forms/base_form.rb | 6 ++++++ app/forms/register/form.rb | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/forms/base_form.rb b/app/forms/base_form.rb index be1c1e1a1..317ad0f6d 100644 --- a/app/forms/base_form.rb +++ b/app/forms/base_form.rb @@ -50,4 +50,10 @@ class BaseForm def strip(str) str.to_s.strip.presence end + + # 1 手机类型;0 邮箱类型 + # 注意新版的login是自动名生成的 + def phone_mail_type value + value =~ /^1\d{10}$/ ? 1 : 0 + end end diff --git a/app/forms/register/form.rb b/app/forms/register/form.rb index bad7a23e6..f0aa488f2 100644 --- a/app/forms/register/form.rb +++ b/app/forms/register/form.rb @@ -10,7 +10,8 @@ module Register def check! Rails.logger.info "Register::Form params: code: #{code}; login: #{login}; namespace: #{namespace}; password: #{password}; type: #{type}" - db_verifi_code = + type = phone_mail_type(strip(login)) + db_verifi_code = if type == 1 check_phone(login) VerificationCode.where(phone: login, code: code, code_type: 1).last From b1884d30d501887ca764858132fe62f14eddcedf Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 20 Jan 2022 09:52:44 +0800 Subject: [PATCH 2/8] fix: detail result delay --- app/views/repositories/detail.json.jbuilder | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/views/repositories/detail.json.jbuilder b/app/views/repositories/detail.json.jbuilder index 9381c4737..508d4c658 100644 --- a/app/views/repositories/detail.json.jbuilder +++ b/app/views/repositories/detail.json.jbuilder @@ -49,6 +49,14 @@ if @result[:repo] json.empty @result[:repo]['empty'] json.full_name @result[:repo]['full_name'] json.private @result[:repo]['private'] +else + json.size 0 + json.ssh_url nil + json.clone_url nil + json.default_branch 'master' + json.empty nil + json.full_name nil + json.private !@project.is_public end json.license_name @project.license_name json.branches_count @result[:branch_tag_total_count].present? ? (@result[:branch_tag_total_count]['branch_count'] || 0) : 0 From 490957ec3bb560de2e0ff8d3e1b5357e23fbaa8c Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 20 Jan 2022 09:41:25 +0800 Subject: [PATCH 3/8] fix: contributor error rescue --- app/controllers/repositories_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 5ebc00b3f..e83bd0e79 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -152,6 +152,8 @@ class RepositoriesController < ApplicationController else @contributors = Gitea::Repository::Contributors::GetService.call(@owner, @repository.identifier) end + rescue + @contributors = [] end def edit From 099fc52e00ab8158b81e0037cade22f73f0c07dd Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 20 Jan 2022 09:42:55 +0800 Subject: [PATCH 4/8] fix: contributor error rescue --- app/controllers/repositories_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index e83bd0e79..c42051e0b 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -150,7 +150,8 @@ class RepositoriesController < ApplicationController if params[:filepath].present? || @project.educoder? @contributors = [] else - @contributors = Gitea::Repository::Contributors::GetService.call(@owner, @repository.identifier) + result = Gitea::Repository::Contributors::GetService.call(@owner, @repository.identifier) + @contributors = result.is_a?(Hash) && result.key?(:status) ? [] : result end rescue @contributors = [] From 1c7e414aa4fe0375bde1ee9008b8e1eed7386822 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 20 Jan 2022 09:29:26 +0800 Subject: [PATCH 5/8] fix: owner allow nil --- app/views/owners/show.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/owners/show.json.jbuilder b/app/views/owners/show.json.jbuilder index db0a80854..82a1c099a 100644 --- a/app/views/owners/show.json.jbuilder +++ b/app/views/owners/show.json.jbuilder @@ -1,4 +1,4 @@ -json.type @owner.type +json.type @owner&.type if @owner.is_a?(Organization) json.partial! "organizations/organizations/detail", organization: @owner json.can_create_project @can_create_project From e14936e8200220015eaad33c6c4a772888e209f3 Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 24 Jan 2022 10:00:44 +0800 Subject: [PATCH 6/8] fix: issues select count --- app/controllers/issues_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 73b3ee4c3..f6244a269 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -27,11 +27,11 @@ class IssuesController < ApplicationController @filter_issues = @filter_issues.where("subject LIKE ? OR description LIKE ? ", "%#{params[:search]}%", "%#{params[:search]}%") if params[:search].present? @open_issues = @all_issues.where.not(status_id: IssueStatus::CLOSED) @close_issues = @all_issues.where(status_id: IssueStatus::CLOSED) - @assign_to_me = @filter_issues.where(assigned_to_id: current_user&.id) - @my_published = @filter_issues.where(author_id: current_user&.id) scopes = Issues::ListQueryService.call(issues,params.delete_if{|k,v| v.blank?}, "Issue") @issues_size = scopes.size @issues = paginate(scopes) + @assign_to_me = @issues.where(assigned_to_id: current_user&.id) + @my_published = @issues.where(author_id: current_user&.id) respond_to do |format| format.json From 237b0afb0891f3b73d75b013bb147f53431fff6b Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 24 Jan 2022 10:44:46 +0800 Subject: [PATCH 7/8] fix: team user build use find or create by --- app/models/team_user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/team_user.rb b/app/models/team_user.rb index 9f90bc15b..fce0e67a4 100644 --- a/app/models/team_user.rb +++ b/app/models/team_user.rb @@ -29,7 +29,7 @@ class TeamUser < ApplicationRecord before_destroy :remove_project_member def self.build(organization_id, user_id, team_id) - self.create!(organization_id: organization_id, user_id: user_id, team_id: team_id) + self.find_or_create_by!(organization_id: organization_id, user_id: user_id, team_id: team_id) end def remove_project_member From 380ca3a0661b7ca7efea24e0e8abc0ec21fd6f81 Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 24 Jan 2022 14:26:24 +0800 Subject: [PATCH 8/8] fix: projects query rule --- app/models/concerns/matchable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/matchable.rb b/app/models/concerns/matchable.rb index aa9fbe817..5c013f951 100644 --- a/app/models/concerns/matchable.rb +++ b/app/models/concerns/matchable.rb @@ -5,7 +5,7 @@ module Matchable scope :with_project_category, ->(category_id) { where(project_category_id: category_id) unless category_id.blank? } scope :with_project_language, ->(language_id) { where(project_language_id: language_id) unless language_id.blank? } scope :with_project_type, ->(project_type) { where(project_type: project_type) if Project.project_types.include?(project_type) } - scope :by_name_or_identifier, ->(search) { where("name like :search or identifier LIKE :search", :search => "#{search.split(" ").join('|')}%") unless search.blank? } + scope :by_name_or_identifier, ->(search) { where("name like :search or identifier LIKE :search", :search => "%#{search.split(" ").join('|')}%") unless search.blank? } end end