chore: snapshot production code before Apple Design UI refinement

This commit is contained in:
lingniu
2026-09-17 18:05:57 +08:00
parent 9f0a87f49e
commit f7e7176f88
90 changed files with 8990 additions and 328 deletions
@@ -0,0 +1,46 @@
// Reproject explicitly listed, backed-up mileage days using the live writer SQL.
package main
import (
"context"
"database/sql"
"encoding/json"
"flag"
"fmt"
_ "github.com/go-sql-driver/mysql"
"lingniu-vehicle-ingest/go/vehicle-gateway/internal/envelope"
"lingniu-vehicle-ingest/go/vehicle-gateway/internal/stats"
"os"
"time"
)
func main() {
input := flag.String("input", "", "JSON array of vin/date/protocol")
flag.Parse()
b, e := os.ReadFile(*input)
must(e)
var rows []struct {
VIN string `json:"vin"`
Date string `json:"date"`
Protocol string `json:"protocol"`
}
must(json.Unmarshal(b, &rows))
db, e := sql.Open("mysql", os.Getenv("MYSQL_DSN"))
must(e)
defer db.Close()
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
defer cancel()
for i, r := range rows {
must(stats.ProjectDailyMileage(ctx, db, r.VIN, r.Date, envelope.Protocol(r.Protocol)))
if (i+1)%500 == 0 {
fmt.Printf("projected=%d/%d\n", i+1, len(rows))
}
}
fmt.Printf("completed=%d\n", len(rows))
}
func must(e error) {
if e != nil {
fmt.Fprintln(os.Stderr, e)
os.Exit(1)
}
}