diff --git a/go/svc/invoice/statusz.go b/go/svc/invoice/statusz.go index f0762994..525d61ee 100644 --- a/go/svc/invoice/statusz.go +++ b/go/svc/invoice/statusz.go @@ -4,6 +4,8 @@ import ( "context" "fmt" "net/http" + "sort" + "time" "code.hackerspace.pl/hscloud/go/mirko" "code.hackerspace.pl/hscloud/go/statusz" @@ -31,8 +33,8 @@ const invoicesFragment = ` {{ .Msg }}
Internal ID | Number | +Created/Issued | Customer | Amount (net) | Actions | @@ -43,8 +45,8 @@ const invoicesFragment = ` {{ else }}
---|---|---|---|---|---|
{{ .Uid }} | {{ .FinalUid }} | +{{ .DatePretty.Format "2006/01/02 15:04:05" }} | {{ index .Data.CustomerBilling 0 }} | {{ .TotalNetPretty }} | @@ -59,6 +61,7 @@ const invoicesFragment = ` type templateInvoice struct { *pb.Invoice TotalNetPretty string + DatePretty time.Time } func (s *service) setupStatusz(m *mirko.Mirko) { @@ -73,6 +76,7 @@ func (s *service) setupStatusz(m *mirko.Mirko) { res.Invoices[i] = templateInvoice{ Invoice: inv, TotalNetPretty: fmt.Sprintf("%.2f %s", float64(inv.TotalNet)/100, inv.Unit), + DatePretty: time.Unix(0, inv.Date), } } @@ -80,6 +84,8 @@ func (s *service) setupStatusz(m *mirko.Mirko) { glog.Errorf("Could not get invoices for statusz: %v", err) res.Msg = fmt.Sprintf("Could not get invoices: %v", err) } + + sort.Slice(res.Invoices, func(i, j int) bool { return res.Invoices[i].Date > res.Invoices[j].Date }) return res }) |