updates on the api endpoints on the customer page and more
This commit is contained in:
62
scratch/check_latest.go
Normal file
62
scratch/check_latest.go
Normal file
@@ -0,0 +1,62 @@
|
||||
//go:build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"doormile/config"
|
||||
"doormile/db"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
_ = godotenv.Load()
|
||||
cfg := config.Load()
|
||||
db.Connect(cfg)
|
||||
if db.DB == nil {
|
||||
log.Fatal("no DB")
|
||||
}
|
||||
type b struct {
|
||||
Bookingid int
|
||||
Bookingno string
|
||||
Bookingsource string
|
||||
Status string
|
||||
Tenantid *int
|
||||
Appcustomerid int
|
||||
Pickuppincode string
|
||||
Pickuplatitude float64
|
||||
Createdat string
|
||||
}
|
||||
var rows []b
|
||||
db.DB.Raw(`SELECT bookingid,bookingno,bookingsource,status,tenantid,appcustomerid,
|
||||
pickuppincode,pickuplatitude,createdat::text
|
||||
FROM pickupbookings ORDER BY bookingid DESC LIMIT 12`).Scan(&rows)
|
||||
fmt.Println("=== 12 newest bookings (any source) ===")
|
||||
for _, r := range rows {
|
||||
tn := "NULL"
|
||||
if r.Tenantid != nil {
|
||||
tn = fmt.Sprint(*r.Tenantid)
|
||||
}
|
||||
fmt.Printf(" #%-5d src=%-13q status=%-24s tenant=%-5s cust=%-4d pin=%-7s lat=%.4f %s\n",
|
||||
r.Bookingid, r.Bookingsource, r.Status, tn, r.Appcustomerid,
|
||||
r.Pickuppincode, r.Pickuplatitude, r.Createdat)
|
||||
}
|
||||
|
||||
fmt.Println("\n=== exact distinct bookingsource values (byte-for-byte) ===")
|
||||
type s struct {
|
||||
V string
|
||||
N int64
|
||||
}
|
||||
var ss []s
|
||||
db.DB.Raw(`SELECT '['||bookingsource||']' v, count(*) n FROM pickupbookings GROUP BY 1 ORDER BY n DESC`).Scan(&ss)
|
||||
for _, x := range ss {
|
||||
fmt.Printf(" %-20s %d\n", x.V, x.N)
|
||||
}
|
||||
|
||||
var appTotal int64
|
||||
db.DB.Raw(`SELECT count(*) FROM pickupbookings WHERE bookingsource='Customer_App'`).Scan(&appTotal)
|
||||
fmt.Printf("\nCustomer_App bookings the console page should list: %d\n", appTotal)
|
||||
}
|
||||
Reference in New Issue
Block a user