Busqueda con estilo

This commit is contained in:
Roberto Alsina 2024-08-20 12:14:08 -03:00
parent e8483662e1
commit 8509a15f68
3 changed files with 31 additions and 30 deletions

View File

@ -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

View File

@ -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);
});
}
</script>

View File

@ -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