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 diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 5ebc00b3f..c42051e0b 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -150,8 +150,11 @@ 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 = [] end def edit diff --git a/app/forms/register/form.rb b/app/forms/register/form.rb index 6800fa1de..ebf0d02fb 100644 --- a/app/forms/register/form.rb +++ b/app/forms/register/form.rb @@ -9,11 +9,9 @@ module Register validate :check! def check! - Rails.logger.info "Register::Form params: code: #{code}; login: #{login}; - namespace: #{namespace}; password: #{password}; password_confirmation: #{password_confirmation}" - + Rails.logger.info "Register::Form params: code: #{code}; login: #{login}; namespace: #{namespace}; password: #{password}; type: #{type}" type = phone_mail_type(strip(login)) - db_verifi_code = + db_verifi_code = if type == 1 check_phone(login) VerificationCode.where(phone: login, code: code, code_type: 1).last 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 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 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