feat: aggregate daily payment history by hour
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package analytics
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPeerComparisonSupported(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -11,3 +14,27 @@ func TestPeerComparisonSupported(t *testing.T) {
|
||||
t.Fatal("peerComparisonSupported() = false for merchant scope")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPaymentHistoryQueryUsesHoursForDay(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
query, capacity := paymentHistoryQuery("DAY")
|
||||
if !strings.Contains(query, "local_hour") || !strings.Contains(query, "EXTRACT(HOUR") {
|
||||
t.Fatalf("paymentHistoryQuery(DAY) does not group by local hour:\n%s", query)
|
||||
}
|
||||
if capacity != 24 {
|
||||
t.Fatalf("paymentHistoryQuery(DAY) capacity = %d, want 24", capacity)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPaymentHistoryQueryKeepsDatesForLongerPeriods(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
query, capacity := paymentHistoryQuery("WEEK")
|
||||
if strings.Contains(query, "EXTRACT(HOUR") {
|
||||
t.Fatalf("paymentHistoryQuery(WEEK) unexpectedly groups by hour:\n%s", query)
|
||||
}
|
||||
if capacity != 93 {
|
||||
t.Fatalf("paymentHistoryQuery(WEEK) capacity = %d, want 93", capacity)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user