mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-08 21:06:24 +08:00
Merge branch 'release/1.28.0' into develop
This commit is contained in:
commit
7b40b43922
3 changed files with 33 additions and 22 deletions
|
@ -29,13 +29,18 @@ class AtWhoController < ApplicationController
|
||||||
else
|
else
|
||||||
Repository.active.accessible_by_teams(@team).first
|
Repository.active.accessible_by_teams(@team).first
|
||||||
end
|
end
|
||||||
if repository && can_read_repository?(repository)
|
|
||||||
items = SmartAnnotation.new(current_user, current_team, @query)
|
|
||||||
.repository_rows(repository, params[:assignable_my_module_id])
|
|
||||||
repository_id = repository.id
|
|
||||||
else
|
|
||||||
items = []
|
items = []
|
||||||
repository_id = nil
|
repository_id = nil
|
||||||
|
|
||||||
|
if repository && can_read_repository?(repository)
|
||||||
|
assignable_my_module =
|
||||||
|
if params[:assignable_my_module_id].present?
|
||||||
|
MyModule.viewable_by_user(current_user, @team).find_by(id: params[:assignable_my_module_id])
|
||||||
|
end
|
||||||
|
items = SmartAnnotation.new(current_user, current_team, @query)
|
||||||
|
.repository_rows(repository, assignable_my_module&.id)
|
||||||
|
repository_id = repository.id
|
||||||
end
|
end
|
||||||
render json: {
|
render json: {
|
||||||
res: [
|
res: [
|
||||||
|
|
|
@ -38,34 +38,40 @@ module Activities
|
||||||
|
|
||||||
def filter_users!
|
def filter_users!
|
||||||
@activity_filters = @activity_filters.where(
|
@activity_filters = @activity_filters.where(
|
||||||
"NOT(filter ? 'users') OR filter -> 'users' @> '\"#{@activity.owner_id}\"'"
|
"NOT(filter ? 'users') OR filter -> 'users' @> '\":owner_id\"'", owner_id: @activity.owner_id
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_types!
|
def filter_types!
|
||||||
@activity_filters = @activity_filters.where(
|
@activity_filters = @activity_filters.where(
|
||||||
"NOT(filter ? 'types') OR filter -> 'types' @> '\"#{@activity.type_of_before_type_cast}\"'"
|
"NOT(filter ? 'types') OR filter -> 'types' @> '\":type_of\"'", type_of: @activity.type_of_before_type_cast
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_teams!
|
def filter_teams!
|
||||||
@activity_filters = @activity_filters.where(
|
@activity_filters = @activity_filters.where(
|
||||||
"NOT(filter ? 'teams') OR filter -> 'teams' @> '\"#{@activity.team_id}\"'"
|
"NOT(filter ? 'teams') OR filter -> 'teams' @> '\":team_id\"'", team_id: @activity.team_id
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_subjects!
|
def filter_subjects!
|
||||||
parents = @activity.subject_parents
|
parents = @activity.subject_parents
|
||||||
|
filtered_by_subject = @activity_filters
|
||||||
|
|
||||||
@activity_filters = @activity_filters.where(
|
filtered_by_subject =
|
||||||
"NOT(filter ? 'subjects') OR "\
|
@activity_filters
|
||||||
"filter -> 'subjects' -> 'Project' @> '\"#{@activity.project_id}\"' OR "\
|
.where("NOT(filter ? 'subjects')")
|
||||||
"filter -> 'subjects' -> '#{@activity.subject_type}' @> '\"#{@activity.subject_id}\"'" +
|
.or(@activity_filters.where("filter -> 'subjects' -> 'Project' @> '\":subject_id\"'",
|
||||||
(parents.any? ? ' OR ' : '') +
|
subject_id: @activity.project_id))
|
||||||
parents.map do |subject|
|
.or(@activity_filters.where("filter -> 'subjects' -> :subject_type @> '\":subject_id\"'",
|
||||||
"filter -> 'subjects' -> '#{subject.class}' @> '\"#{subject.id}\"'"
|
subject_type: @activity.subject_type, subject_id: @activity.subject_id))
|
||||||
end.join(' OR ')
|
parents.each do |parent|
|
||||||
)
|
filtered_by_subject =
|
||||||
|
filtered_by_subject
|
||||||
|
.or(@activity_filters.where("filter -> 'subjects' -> :subject_type @> '\":subject_id\"'",
|
||||||
|
subject_type: parent.class, subject_id: parent.id))
|
||||||
|
end
|
||||||
|
@activity_filters = filtered_by_subject
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,16 +36,16 @@ class SmartAnnotation
|
||||||
end
|
end
|
||||||
|
|
||||||
def repository_rows(repository, my_module_id)
|
def repository_rows(repository, my_module_id)
|
||||||
res = RepositoryRow
|
res = repository
|
||||||
|
.repository_rows
|
||||||
.active
|
.active
|
||||||
.where(repository: repository)
|
|
||||||
.search_by_name_and_id(@current_user, @current_team, @query)
|
.search_by_name_and_id(@current_user, @current_team, @query)
|
||||||
.limit(Constants::ATWHO_SEARCH_LIMIT + 1)
|
.limit(Constants::ATWHO_SEARCH_LIMIT + 1)
|
||||||
|
|
||||||
if my_module_id.present?
|
if my_module_id.present?
|
||||||
res = res.joins('LEFT OUTER JOIN "my_module_repository_rows" "current_my_module_repository_rows" ' \
|
res = res.joins('LEFT OUTER JOIN "my_module_repository_rows" "current_my_module_repository_rows" ' \
|
||||||
'ON "current_my_module_repository_rows"."repository_row_id" = "repository_rows"."id" ' \
|
'ON "current_my_module_repository_rows"."repository_row_id" = "repository_rows"."id" ' \
|
||||||
'AND "current_my_module_repository_rows"."my_module_id" = ' + my_module_id.to_s)
|
'AND "current_my_module_repository_rows"."my_module_id" = ' + Integer(my_module_id).to_s)
|
||||||
.select('repository_rows.*',
|
.select('repository_rows.*',
|
||||||
'CASE WHEN current_my_module_repository_rows.id IS NOT NULL ' \
|
'CASE WHEN current_my_module_repository_rows.id IS NOT NULL ' \
|
||||||
'THEN true ELSE false END as row_assigned')
|
'THEN true ELSE false END as row_assigned')
|
||||||
|
|
Loading…
Add table
Reference in a new issue