forked from Gitlink/forgeplus
Merge branch 'develop' into standalone_develop
This commit is contained in:
commit
d98b5b9f72
|
@ -8,14 +8,17 @@ class Organizations::ProjectsController < Organizations::BaseController
|
||||||
.joins(team_projects: {team: :team_users})
|
.joins(team_projects: {team: :team_users})
|
||||||
.where(team_users: {user_id: current_user.id}).to_sql
|
.where(team_users: {user_id: current_user.id}).to_sql
|
||||||
@projects = Project.from("( #{ public_projects_sql} UNION #{ private_projects_sql } ) AS projects")
|
@projects = Project.from("( #{ public_projects_sql} UNION #{ private_projects_sql } ) AS projects")
|
||||||
|
# 表情处理
|
||||||
@projects = @projects.ransack(name_or_identifier_cont: params[:search]).result if params[:search].present?
|
keywords = params[:search].to_s.each_char.select { |c| c.bytes.first < 240 }.join('')
|
||||||
|
@projects = @projects.ransack(name_or_identifier_cont: keywords).result if params[:search].present?
|
||||||
@projects = @projects.includes(:owner).order("projects.#{sort} #{sort_direction}")
|
@projects = @projects.includes(:owner).order("projects.#{sort} #{sort_direction}")
|
||||||
@projects = paginate(@projects)
|
@projects = paginate(@projects)
|
||||||
end
|
end
|
||||||
|
|
||||||
def search
|
def search
|
||||||
tip_exception("请输入搜索关键词") if params[:search].nil?
|
tip_exception("请输入搜索关键词") if params[:search].nil?
|
||||||
|
# 表情处理
|
||||||
|
keywords = params[:search].to_s.each_char.select { |c| c.bytes.first < 240 }.join('')
|
||||||
public_projects_sql = @organization.projects.where(is_public: true).to_sql
|
public_projects_sql = @organization.projects.where(is_public: true).to_sql
|
||||||
private_projects_sql = @organization.projects
|
private_projects_sql = @organization.projects
|
||||||
.where(is_public: false)
|
.where(is_public: false)
|
||||||
|
@ -23,7 +26,7 @@ class Organizations::ProjectsController < Organizations::BaseController
|
||||||
.where(team_users: {user_id: current_user.id}).to_sql
|
.where(team_users: {user_id: current_user.id}).to_sql
|
||||||
@projects = Project.from("( #{ public_projects_sql} UNION #{ private_projects_sql } ) AS projects")
|
@projects = Project.from("( #{ public_projects_sql} UNION #{ private_projects_sql } ) AS projects")
|
||||||
|
|
||||||
@projects = @projects.ransack(name_or_identifier_cont: params[:search]).result
|
@projects = @projects.ransack(name_or_identifier_cont: keywords).result
|
||||||
@projects = @projects.includes(:owner).order("projects.#{sort} #{sort_direction}")
|
@projects = @projects.includes(:owner).order("projects.#{sort} #{sort_direction}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -240,6 +240,8 @@ class Project < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.search_project(search)
|
def self.search_project(search)
|
||||||
|
# 表情处理
|
||||||
|
search = search.to_s.each_char.select { |c| c.bytes.first < 240 }.join('')
|
||||||
ransack(name_or_identifier_cont: search)
|
ransack(name_or_identifier_cont: search)
|
||||||
end
|
end
|
||||||
# 创建者
|
# 创建者
|
||||||
|
|
|
@ -58,8 +58,10 @@ class Projects::ListMyQuery < ApplicationQuery
|
||||||
elsif params[:project_type].to_s === "sync_mirror"
|
elsif params[:project_type].to_s === "sync_mirror"
|
||||||
projects = projects.sync_mirror
|
projects = projects.sync_mirror
|
||||||
end
|
end
|
||||||
|
|
||||||
q = projects.ransack(name_or_identifier_cont: params[:search])
|
# 表情处理
|
||||||
|
keywords = params[:search].to_s.each_char.select { |c| c.bytes.first < 240 }.join('')
|
||||||
|
q = projects.ransack(name_or_identifier_cont: keywords)
|
||||||
|
|
||||||
scope = q.result.includes(:project_category, :project_language,:owner, :repository, :has_pinned_users)
|
scope = q.result.includes(:project_category, :project_language,:owner, :repository, :has_pinned_users)
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,9 @@ class Projects::ListQuery < ApplicationQuery
|
||||||
# items = items.where(id: @ids).by_name_or_identifier(params[:search])
|
# items = items.where(id: @ids).by_name_or_identifier(params[:search])
|
||||||
items = items.where(id: @ids)
|
items = items.where(id: @ids)
|
||||||
else
|
else
|
||||||
items = items.by_name_or_identifier(params[:search]).or(main_collection.where(user_id: Owner.like(params[:search]).pluck(:id)))
|
# 表情处理
|
||||||
|
keywords = params[:search].to_s.each_char.select { |c| c.bytes.first < 240 }.join('')
|
||||||
|
items = items.by_name_or_identifier(keywords).or(main_collection.where(user_id: Owner.like(keywords).pluck(:id)))
|
||||||
end
|
end
|
||||||
items
|
items
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,8 +73,10 @@ class Api::V1::Users::Projects::ListService < ApplicationService
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
projects = projects.with_project_type(project_type)
|
projects = projects.with_project_type(project_type)
|
||||||
|
|
||||||
|
# 表情处理
|
||||||
|
search = search.to_s.each_char.select { |c| c.bytes.first < 240 }.join('')
|
||||||
q = projects.ransack(name_or_identifier_cont: search)
|
q = projects.ransack(name_or_identifier_cont: search)
|
||||||
|
|
||||||
scope = q.result.includes(:project_category, :project_language,:owner, :repository, :has_pinned_users)
|
scope = q.result.includes(:project_category, :project_language,:owner, :repository, :has_pinned_users)
|
||||||
|
|
Loading…
Reference in New Issue