Fixing stuff
This commit is contained in:
parent
6d7a571a55
commit
6ed644d1d0
@ -84,11 +84,12 @@ class Handler
|
|||||||
FROM hombres WHERE nombre='#{nombre}'
|
FROM hombres WHERE nombre='#{nombre}'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
hombres = mujeres = 0
|
||||||
DB.open("postgres://#{USER}:#{PASS}@10.61.0.1:5432/nombres") do |cursor|
|
DB.open("postgres://#{USER}:#{PASS}@10.61.0.1:5432/nombres") do |cursor|
|
||||||
cursor.query sql1 do |result|
|
cursor.query sql1 do |result|
|
||||||
mujeres = result.read(Int32)
|
mujeres = result.read(Int32)
|
||||||
end
|
end
|
||||||
cursor.query sql2 do |_|
|
cursor.query sql2 do |result|
|
||||||
hombres = result.read(Int32)
|
hombres = result.read(Int32)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -99,8 +100,8 @@ class Handler
|
|||||||
end
|
end
|
||||||
|
|
||||||
def split_por_genero(nombres)
|
def split_por_genero(nombres)
|
||||||
femeninos = Array(Array(String | Int32)).new
|
femeninos = Array(Tuple(Int32, String)).new
|
||||||
masculinos = Array(Array(String | Int32)).new
|
masculinos = Array(Tuple(Int32, String)).new
|
||||||
nombres.map { |nombre|
|
nombres.map { |nombre|
|
||||||
fem = feminidad(nombre[1])
|
fem = feminidad(nombre[1])
|
||||||
# El overlap en 0.5 es intencional!
|
# El overlap en 0.5 es intencional!
|
||||||
@ -193,9 +194,9 @@ class Handler
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
datos = [] of Tuple(Int32, String)
|
||||||
DB.open("postgres://#{USER}:#{PASS}@10.61.0.1:5432/nombres") do |cursor|
|
DB.open("postgres://#{USER}:#{PASS}@10.61.0.1:5432/nombres") do |cursor|
|
||||||
cursor.query sql do |result_set|
|
cursor.query sql do |result_set|
|
||||||
datos = [] of Tuple(Int32, String)
|
|
||||||
result_set.each do
|
result_set.each do
|
||||||
valor = result_set.read(Int32)
|
valor = result_set.read(Int32)
|
||||||
nombre = result_set.read(String)
|
nombre = result_set.read(String)
|
||||||
@ -204,7 +205,6 @@ class Handler
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if datos.empty?
|
if datos.empty?
|
||||||
# This is bad 😀
|
# This is bad 😀
|
||||||
return {
|
return {
|
||||||
|
@ -67,8 +67,8 @@ class Handler
|
|||||||
def normalize_name(s)
|
def normalize_name(s)
|
||||||
# Remove diacritics, turn lowercase
|
# Remove diacritics, turn lowercase
|
||||||
normalized = s.unicode_normalize(:nfkd).chars
|
normalized = s.unicode_normalize(:nfkd).chars
|
||||||
normalized.reject! { |_|
|
normalized.reject! { |character|
|
||||||
!ccharacter.ascii_letter?
|
!character.ascii_letter?
|
||||||
}.join("").downcase
|
}.join("").downcase
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user