add basic schema and sync function, sorting by appointment type

This commit is contained in:
Miloš Jovanović 2026-09-09 23:46:35 +02:00
parent b665bf63a0
commit 40f16346f5
4 changed files with 207 additions and 33 deletions

21
main.go
View file

@ -3,9 +3,28 @@ package main
import (
"log"
"net/http"
"strings"
"os"
)
// ELIGIBLE_APPOINTMENTS is a comma-separated list of appointment type
// labels, matched case-insensitively.
func loadEligible() map[string]bool {
raw := os.Getenv("ELIGIBLE_APPOINTMENTS")
if raw == "" {
raw = "senate,recall"
}
set := map[string]bool{}
for _, s := range strings.Split(raw, ",") {
if s = strings.ToLower(strings.TrimSpace(s)); s != "" {
set[s] = true
}
}
log.Printf("eligible appointment types: %v", set)
return set
}
// get other variables, like api key and webhook secret
func main() {
secret := os.Getenv("WEBHOOK_SECRET")
if secret == "" {
@ -37,7 +56,7 @@ func main() {
log.Println("DRY_RUN set: no writes will be sent to Solidarity Tech")
}
srv := NewServer(NewClient(apiKey, dryRun), store, secret)
srv := NewServer(NewClient(apiKey, dryRun), store, secret, loadEligible())
log.Println("listening on :8080")
log.Fatal(http.ListenAndServe(":8080", srv.Routes()))
}