Parcourir la source

Added period start & end dates to service & supplier views, created nicedate() helper

pull/3/head
Adrian Short il y a 14 ans
Parent
révision
864a693b19
5 fichiers modifiés avec 28 ajouts et 6 suppressions
  1. +9
    -0
      app.rb
  2. +1
    -1
      views/payment.haml
  3. +1
    -1
      views/scoreboard.haml
  4. +11
    -2
      views/service.haml
  5. +6
    -2
      views/supplier.haml

+ 9
- 0
app.rb Voir le fichier

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


+ 1
- 1
views/payment.haml Voir le fichier

@@ -4,7 +4,7 @@
%table
%tr
%td Date
%td= @payment.d.strftime("%d %b %Y")
%td= nicedate(@payment.d)
%tr
%td Directorate
%td


+ 1
- 1
views/scoreboard.haml Voir le fichier

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


+ 11
- 2
views/service.haml Voir le fichier

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


+ 6
- 2
views/supplier.haml Voir le fichier

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


Chargement…
Annuler
Enregistrer