fix: projects load by invite code slowly
This commit is contained in:
parent
7c43f2d8fc
commit
818317c292
|
@ -61,6 +61,7 @@
|
||||||
#
|
#
|
||||||
# index_projects_on_forked_from_project_id (forked_from_project_id)
|
# index_projects_on_forked_from_project_id (forked_from_project_id)
|
||||||
# index_projects_on_identifier (identifier)
|
# index_projects_on_identifier (identifier)
|
||||||
|
# index_projects_on_invite_code (invite_code)
|
||||||
# index_projects_on_is_public (is_public)
|
# index_projects_on_is_public (is_public)
|
||||||
# index_projects_on_lft (lft)
|
# index_projects_on_lft (lft)
|
||||||
# index_projects_on_name (name)
|
# index_projects_on_name (name)
|
||||||
|
@ -74,6 +75,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Project < ApplicationRecord
|
class Project < ApplicationRecord
|
||||||
include Matchable
|
include Matchable
|
||||||
include Publicable
|
include Publicable
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Projects::ApplyJoinService < ApplicationService
|
||||||
private
|
private
|
||||||
|
|
||||||
def project
|
def project
|
||||||
@_project ||= Project.find_by('binary(invite_code) = ? ',"#{params[:code].to_s.strip}")
|
@_project ||= Project.find_by(invite_code: params[:code].to_s.strip)
|
||||||
end
|
end
|
||||||
|
|
||||||
def role_value
|
def role_value
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
class AddInviteCodeIndexToProjects < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_index :projects, :invite_code
|
||||||
|
execute <<-SQL
|
||||||
|
ALTER TABLE projects MODIFY COLUMN invite_code VARCHAR(255) BINARY CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL;
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue