From 864a693b19573a3a0672cca48c95be174e75aa79 Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Thu, 26 Aug 2010 16:44:25 +0100 Subject: [PATCH] Added period start & end dates to service & supplier views, created nicedate() helper --- app.rb | 9 +++++++++ views/payment.haml | 2 +- views/scoreboard.haml | 2 +- views/service.haml | 13 +++++++++++-- views/supplier.haml | 8 ++++++-- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/app.rb b/app.rb index 46e2bf4..e982b69 100644 --- a/app.rb +++ b/app.rb @@ -14,6 +14,11 @@ helpers do def yesno(boolean) boolean == true ? 'Yes' : 'No' end + + def nicedate(d) + d.strftime("%d %b %Y") + end + end get '/' do @@ -52,6 +57,8 @@ get '/suppliers/:slug' do @avg = @supplier.payments.avg(:amount) @max = @supplier.payments.max(:amount) @min = @supplier.payments.min(:amount) + @d_start = @supplier.payments.min(:d) + @d_end = @supplier.payments.max(:d) haml :supplier end @@ -89,6 +96,8 @@ get '/services/:slug' do @avg = @service.payments.avg(:amount) @max = @service.payments.max(:amount) @min = @service.payments.min(:amount) + @d_start = @service.payments.min(:d) + @d_end = @service.payments.max(:d) @results = repository(:default).adapter.query(" SELECT s.name AS supplier_name, s.slug AS supplier_slug, SUM(p.amount) AS total diff --git a/views/payment.haml b/views/payment.haml index 9bfeb6e..ed29ffc 100644 --- a/views/payment.haml +++ b/views/payment.haml @@ -4,7 +4,7 @@ %table %tr %td Date - %td= @payment.d.strftime("%d %b %Y") + %td= nicedate(@payment.d) %tr %td Directorate %td diff --git a/views/scoreboard.haml b/views/scoreboard.haml index ad9f254..798af9a 100644 --- a/views/scoreboard.haml +++ b/views/scoreboard.haml @@ -29,7 +29,7 @@ %td= yesno(council.machine_readable) %td= council.start_d.strftime("%b %Y") %td= council.end_d.strftime("%b %Y") - %td= council.updated_at.strftime("%d %b %Y") + %td= nicedate(council.updated_at) %p.highlight.noprint This scoreboard data is free for you to use according to the diff --git a/views/service.haml b/views/service.haml index 18667cc..f54fe26 100644 --- a/views/service.haml +++ b/views/service.haml @@ -25,7 +25,11 @@ .grid_9 - %h3 Summary + %h3 + Summary for + = nicedate(@d_start) + to + = nicedate(@d_end) %table %tr @@ -42,7 +46,12 @@ %td.right= commify(sprintf("£%0d", @min)) %td.right= commify(sprintf("£%0d", @avg)) - %h3 Suppliers by Spend + %h3 + Suppliers by Spend for + = nicedate(@d_start) + to + = nicedate(@d_end) + %table %tr diff --git a/views/supplier.haml b/views/supplier.haml index ecf052e..82dc793 100644 --- a/views/supplier.haml +++ b/views/supplier.haml @@ -18,8 +18,12 @@ %a{ :href => "/suppliers/#{@supplier.slug}.csv" } Download data as CSV - %h3 Summary - + %h3 + Summary for + = nicedate(@d_start) + to + = nicedate(@d_end) + %table %tr %th.right Payments