go/svc/invoice: statusz cleanups
- Remove internal ID
- Sort by time
diff --git a/go/svc/invoice/statusz.go b/go/svc/invoice/statusz.go
index f076299..525d61e 100644
--- a/go/svc/invoice/statusz.go
+++ b/go/svc/invoice/statusz.go
@@ -4,6 +4,8 @@
"context"
"fmt"
"net/http"
+ "sort"
+ "time"
"code.hackerspace.pl/hscloud/go/mirko"
"code.hackerspace.pl/hscloud/go/statusz"
@@ -31,8 +33,8 @@
{{ .Msg }}
<table class="table">
<tr>
- <th>Internal ID</th>
<th>Number</th>
+ <th>Created/Issued</th>
<th>Customer</th>
<th>Amount (net)</th>
<th>Actions</th>
@@ -43,8 +45,8 @@
{{ else }}
<tr style="opacity: 0.5">
{{ end }}
- <td>{{ .Uid }}</td>
<td>{{ .FinalUid }}</td>
+ <td>{{ .DatePretty.Format "2006/01/02 15:04:05" }}</td>
<td>{{ index .Data.CustomerBilling 0 }}</td>
<td>{{ .TotalNetPretty }}</td>
<td>
@@ -59,6 +61,7 @@
type templateInvoice struct {
*pb.Invoice
TotalNetPretty string
+ DatePretty time.Time
}
func (s *service) setupStatusz(m *mirko.Mirko) {
@@ -73,6 +76,7 @@
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 @@
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
})