Fix rubocop offenses

This commit is contained in:
Alexander Meindl 2021-06-30 19:30:58 +02:00
parent af96b28f90
commit d983b4fb34
4 changed files with 13 additions and 13 deletions

View File

@ -161,8 +161,8 @@ module AdditionalsQuery
db_table = Watcher.table_name
"#{queried_table_name}.id #{operator == '=' ? 'IN' : 'NOT IN'}" \
" (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='#{watchable_type}' AND" \
" #{sql_for_field field, '=', value, db_table, 'user_id'})"
" (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='#{watchable_type}' AND" \
" #{sql_for_field field, '=', value, db_table, 'user_id'})"
end
def sql_for_is_private_field(_field, operator, value)

View File

@ -111,14 +111,14 @@ class Dashboard < ActiveRecord::Base
scope.where.not(visibility: VISIBILITY_PRIVATE).or(scope.where(author_id: user.id))
elsif user.memberships.any?
scope.where("#{table_name}.visibility = ?" \
" OR (#{table_name}.visibility = ? AND #{table_name}.id IN (" \
"SELECT DISTINCT d.id FROM #{table_name} d" \
" INNER JOIN #{table_name_prefix}dashboard_roles#{table_name_suffix} dr ON dr.dashboard_id = d.id" \
" INNER JOIN #{MemberRole.table_name} mr ON mr.role_id = dr.role_id" \
" INNER JOIN #{Member.table_name} m ON m.id = mr.member_id AND m.user_id = ?" \
" INNER JOIN #{Project.table_name} p ON p.id = m.project_id AND p.status <> ?" \
' WHERE d.project_id IS NULL OR d.project_id = m.project_id))' \
" OR #{table_name}.author_id = ?",
" OR (#{table_name}.visibility = ? AND #{table_name}.id IN (" \
"SELECT DISTINCT d.id FROM #{table_name} d" \
" INNER JOIN #{table_name_prefix}dashboard_roles#{table_name_suffix} dr ON dr.dashboard_id = d.id" \
" INNER JOIN #{MemberRole.table_name} mr ON mr.role_id = dr.role_id" \
" INNER JOIN #{Member.table_name} m ON m.id = mr.member_id AND m.user_id = ?" \
" INNER JOIN #{Project.table_name} p ON p.id = m.project_id AND p.status <> ?" \
' WHERE d.project_id IS NULL OR d.project_id = m.project_id))' \
" OR #{table_name}.author_id = ?",
VISIBILITY_PUBLIC,
VISIBILITY_ROLES,
user.id,

View File

@ -18,7 +18,7 @@ module Additionals
class_methods do
def join_enabled_module
"JOIN #{EnabledModule.table_name} ON #{EnabledModule.table_name}.project_id=#{Wiki.table_name}.project_id" \
" AND #{EnabledModule.table_name}.name='wiki'"
" AND #{EnabledModule.table_name}.name='wiki'"
end
end

View File

@ -8,8 +8,8 @@ module Additionals
"{{user(USER_NAME [, format=USER_FORMAT, text=BOOL], avatar=BOOL])}}\n\n" \
"USER_NAME can be user id or user name (login name)\n" \
"USER_FORMATS\n" \
"- system (use system settings) (default)\n- " +
User::USER_FORMATS.keys.join("\n- ") + "\n\n" \
"- system (use system settings) (default)\n- " \
"#{User::USER_FORMATS.keys.join "\n- "}\n\n" \
"Examples:\n\n" \
"{{user(1)}}\n" \
"...Link to user with user id 1\n\n" \