From c00b5b5bb6db89edfa9a514dccb948743cf73222 Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Thu, 14 Dec 2017 12:46:19 +0100 Subject: [PATCH] dane --- app/controllers/home_controller.rb | 6 ++++++ app/views/home/partials/_bb_trades.html.erb | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 1ccd1a8..942f80f 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -29,5 +29,11 @@ class HomeController < ApplicationController def bbt @bbt = BitBayTrade.where('currency_id = ?', @curr_id).order('cast(tid as unsigned) DESC').limit(20) + @bbt_max_lifetime = BitBayTrade.where('currency_id = ?', @curr_id).order('price DESC').first + @bbt_min_lifetime = BitBayTrade.where('currency_id = ?', @curr_id).order('price ASC').first + time = Time.now - 24.hours + @bbt_max_24h = BitBayTrade.where('currency_id = ? AND date > ?', @curr_id,time).order('price DESC').first + @bbt_min_24h = BitBayTrade.where('currency_id = ? AND date > ?', @curr_id,time).order('price ASC').first + end end diff --git a/app/views/home/partials/_bb_trades.html.erb b/app/views/home/partials/_bb_trades.html.erb index 533def8..e05bc14 100644 --- a/app/views/home/partials/_bb_trades.html.erb +++ b/app/views/home/partials/_bb_trades.html.erb @@ -1,3 +1,13 @@ +<% if !@bbt_max_lifetime.blank? %> +
Max (<%= @bbt_max_lifetime.date %>): <%= '%.2f' % @bbt_max_lifetime.price %> Min (<%= @bbt_min_lifetime.date %>): <%= '%.2f' % @bbt_min_lifetime.price %>
+<% else %> +
Brak danych dla tej monety
+<% end %> +<% if !@bbt_max_24h.blank? %> +
Max 24h: <%= '%.2f' % @bbt_max_24h.price %> Min 24h: <%= '%.2f' % @bbt_min_24h.price %>
+<% else %> +
Brak danych z ostatnich 24h
+<% end %>