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})
|
||||
.where(team_users: {user_id: current_user.id}).to_sql
|
||||
@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 = paginate(@projects)
|
||||
end
|
||||
|
||||
def search
|
||||
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
|
||||
private_projects_sql = @organization.projects
|
||||
.where(is_public: false)
|
||||
|
@ -23,7 +26,7 @@ class Organizations::ProjectsController < Organizations::BaseController
|
|||
.where(team_users: {user_id: current_user.id}).to_sql
|
||||
@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}")
|
||||
end
|
||||
|
||||
|
|
|
@ -240,6 +240,8 @@ class Project < ApplicationRecord
|
|||
end
|
||||
|
||||
def self.search_project(search)
|
||||
# 表情处理
|
||||
search = search.to_s.each_char.select { |c| c.bytes.first < 240 }.join('')
|
||||
ransack(name_or_identifier_cont: search)
|
||||
end
|
||||
# 创建者
|
||||
|
|
|
@ -59,7 +59,9 @@ class Projects::ListMyQuery < ApplicationQuery
|
|||
projects = projects.sync_mirror
|
||||
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)
|
||||
|
||||
|
|
|
@ -51,7 +51,9 @@ class Projects::ListQuery < ApplicationQuery
|
|||
# items = items.where(id: @ids).by_name_or_identifier(params[:search])
|
||||
items = items.where(id: @ids)
|
||||
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
|
||||
items
|
||||
end
|
||||
|
|
|
@ -75,6 +75,8 @@ class Api::V1::Users::Projects::ListService < ApplicationService
|
|||
|
||||
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)
|
||||
|
||||
scope = q.result.includes(:project_category, :project_language,:owner, :repository, :has_pinned_users)
|
||||
|
|
Loading…
Reference in New Issue