From 8509a15f68888717272f2524fa3238c90a1e0d11 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Tue, 20 Aug 2024 12:14:08 -0300 Subject: [PATCH] Busqueda con estilo --- busqueda/funko.cr | 12 ++++------ busqueda/public/index.html | 47 ++++++++++++++++++++------------------ historico/funko.cr | 2 +- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/busqueda/funko.cr b/busqueda/funko.cr index e804231..f61b9a2 100644 --- a/busqueda/funko.cr +++ b/busqueda/funko.cr @@ -12,7 +12,7 @@ DBURL = "postgres://#{USER}:#{PASS}@#{DBHOST}:5432/nombres" puts "Connnecting to #{DBURL}" # Create a connection pool to the database -pg = ConnectionPool.new(capacity: 5, timeout: 0.01.seconds) do +pg = ConnectionPool.new(capacity: 5, timeout: 0.2.seconds) do PG.connect(DBURL) end @@ -29,8 +29,6 @@ post "/" do |env| genero = env.params.json["g"].as(String) year = env.params.json["a"].as(String) - p! prefijo, genero, year - prefijo = normalize(prefijo) if !["f", "m"].includes?(genero) genero = nil @@ -132,10 +130,10 @@ post "/" do |env| [row[0].capitalize, row[1]] } - if datos.size > 1 - title = "¿Puede ser ... #{datos[0][1].to_s.titleize}? ¿O capaz que #{datos[1][1].to_s.titleize}? ¡Contame más!" - elsif datos.size == 1 - title = "Me parece que ... #{datos[0][1].to_s.titleize}!" + if datos.size > 2 + title = "¿Puede ser ... #{datos[1][0].to_s.titleize}? ¿O capaz que #{datos[2][0].to_s.titleize}? ¡Contame más!" + elsif datos.size == 2 + title = "Me parece que ... #{datos[1][0].to_s.titleize}!" else title = "No tengo idea!" end diff --git a/busqueda/public/index.html b/busqueda/public/index.html index f93807b..f59ff98 100644 --- a/busqueda/public/index.html +++ b/busqueda/public/index.html @@ -52,33 +52,36 @@ data = json["data"]; console.log(data); data = google.visualization.arrayToDataTable(data); - // var options = { - // title: "", - // animation: { - // startup: true, - // duration: 1000, - // easing: "out", - // }, - // backgroundColor: "#1c212c", - // vAxis: { - // minValue: 0, - // gridlines: { color: "#666" }, - // minorGridlines: { color: "#1c212c" }, - // textStyle: { color: "#aaa" }, - // }, - // hAxis: { - // gridlines: { color: "#666" }, - // minorGridlines: { color: "#1c212c" }, - // textStyle: { color: "#aaa" }, - // }, - // legend: { position: "bottom", textStyle: { color: "#aaa" } }, - // }; + var options = { + title: title, + titleTextStyle: { + color: "#aaa", + }, + animation: { + startup: true, + duration: 1000, + easing: "out", + }, + backgroundColor: "#1c212c", + vAxis: { + minValue: 0, + gridlines: { color: "#666" }, + minorGridlines: { color: "#1c212c" }, + textStyle: { color: "#aaa" } + }, + hAxis: { + gridlines: { color: "#666" }, + minorGridlines: { color: "#1c212c" }, + textStyle: { color: "#aaa" } + }, + legend: { position: 'none'}, + }; var chart = new google.visualization.BarChart( document.getElementById("chart") ); - chart.draw(data); + chart.draw(data, options); }); } diff --git a/historico/funko.cr b/historico/funko.cr index b1719b5..0f7ff6f 100644 --- a/historico/funko.cr +++ b/historico/funko.cr @@ -12,7 +12,7 @@ DBURL = "postgres://#{USER}:#{PASS}@#{DBHOST}:5432/nombres" puts "Connnecting to #{DBURL}" # Create a connection pool to the database -pg = ConnectionPool.new(capacity: 5, timeout: 0.01.seconds) do +pg = ConnectionPool.new(capacity: 5, timeout: 0.2.seconds) do PG.connect(DBURL) end