Browse Source

Considered multiple fullnames in the fullname field

Dmitry Yu Okunev 1 year ago
parent
commit
6c14cb7e80
2 changed files with 13 additions and 7 deletions
  1. 10 5
      app/controllers/people_controller.rb
  2. 3 2
      app/models/person.rb

+ 10 - 5
app/controllers/people_controller.rb

@@ -41,8 +41,11 @@ class PeopleController < ApplicationController
 		people_ht = Hash.new
 
 		Person.preload(:passes).all.each do |person|
-			people_ht[person.GetKey] = Array.new if people_ht[person.GetKey].nil?
-			people_ht[person.GetKey] << person
+			keys = person.GetKeys
+			keys.each do |key|
+				people_ht[key] = Array.new if people_ht[key].nil?
+				people_ht[key] << person
+			end
 		end
 
 		@people = Array.new
@@ -145,9 +148,11 @@ class PeopleController < ApplicationController
 
 		people = Hash.new
 		Person.where("is_actual = 1").all.each do |person|
-			key = person.GetKey
-			people[key] = Array.new if people[key].nil?
-			people[key] << person
+			keys = person.GetKeys
+			keys.each do |key|
+				people[key] = Array.new if people[key].nil?
+				people[key] << person
+			end
 		end
 
 		passes_raw = Hash.new

+ 3 - 2
app/models/person.rb

@@ -44,7 +44,8 @@ class Person < ApplicationRecord
 		return false
 	end
 
-	def GetKey
-		return "#{self.fullname}".delete(' ').delete('?').gsub('Ё', 'Е').gsub('ё', 'е').strip
+	def GetKeys
+		keysJoined = "#{self.fullname}".delete(' ').delete('?').gsub('Ё', 'Е').gsub('ё', 'е').delete(')').gsub('(', ',').strip
+		return keysJoined.split(',')
 	end
 end