Redmine 4.1.1

This commit is contained in:
Manuel Cillero 2020-11-22 21:20:06 +01:00
parent 33e7b881a5
commit 3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2006-2019 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -60,7 +62,8 @@ module Redmine
# eg. hello "bye bye" => ["hello", "bye bye"]
@tokens = @question.scan(%r{((\s|^)"[^"]+"(\s|$)|\S+)}).collect {|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')}
# tokens must be at least 2 characters long
@tokens = @tokens.uniq.select {|w| w.length > 1 }
# but for Chinese characters (Chinese HANZI/Japanese KANJI), tokens can be one character
@tokens = @tokens.uniq.select {|w| w.length > 1 || w =~ /\p{Han}/ }
# no more than 5 tokens to search for
@tokens.slice! 5..-1
end
@ -82,13 +85,11 @@ module Redmine
# Returns the results for the given offset and limit
def results(offset, limit)
result_ids_to_load = result_ids[offset, limit] || []
results_by_scope = Hash.new {|h,k| h[k] = []}
result_ids_to_load.group_by(&:first).each do |scope, scope_and_ids|
klass = scope.singularize.camelcase.constantize
results_by_scope[scope] += klass.search_results_from_ids(scope_and_ids.map(&:last))
end
result_ids_to_load.map do |scope, id|
results_by_scope[scope].detect {|record| record.id == id}
end.compact
@ -110,7 +111,6 @@ module Redmine
cache_key = ActiveSupport::Cache.expand_cache_key(
[@question, @user.id, @scope.sort, @options, project_ids.sort]
)
Redmine::Search.cache_store.fetch(cache_key, :force => !@cache) do
load_result_ids
end