From d32b0bbb71bcce27f7be492bf6aa029bb99ccfd9 Mon Sep 17 00:00:00 2001 From: hootmeow Date: Wed, 14 Oct 2026 15:56:21 -0400 Subject: [PATCH] Make the log parser importable: internal/parser/bflog -> bflog, internal/domain -> domain Other tools (captheflag-uplink) can now reuse the same parser instead of copying it. No behaviour change. Co-Authored-By: Claude Opus 5.5 --- CONTRIBUTING.md | 2 +- README.md | 4 ++-- apps/api/export.go | 2 +- apps/api/main.go | 2 +- apps/api/player.go | 2 +- apps/api/upload.go | 2 +- apps/worker/main.go | 2 +- {internal/parser/bflog => bflog}/parser.go | 2 +- {internal/parser/bflog => bflog}/parser_test.go | 2 +- {internal/domain => domain}/clantag.go | 0 {internal/domain => domain}/clantag_test.go | 0 {internal/domain => domain}/event.go | 0 {internal/domain => domain}/medal.go | 0 fixtures/README.md | 2 +- internal/notify/round.go | 2 +- internal/storage/postgres/store.go | 2 +- 16 files changed, 13 insertions(+), 13 deletions(-) rename {internal/parser/bflog => bflog}/parser.go (99%) rename {internal/parser/bflog => bflog}/parser_test.go (98%) rename {internal/domain => domain}/clantag.go (100%) rename {internal/domain => domain}/clantag_test.go (100%) rename {internal/domain => domain}/event.go (100%) rename {internal/domain => domain}/medal.go (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7ddaed0..e648b1a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,7 +19,7 @@ Thanks for helping improve Spawnpoint! only — see the rollback note in README "Updating"), plus a probe entry in `setup.sh`'s `probe_for` so pre-installer databases skip it correctly. - Parser changes should come with a test in - `internal/parser/bflog/parser_test.go`; real-world log fixtures are welcome + `bflog/parser_test.go`; real-world log fixtures are welcome (see `fixtures/README.md`, sanitize nicknames/chat first). ## Bugs and ideas diff --git a/README.md b/README.md index be539e4..465f947 100644 --- a/README.md +++ b/README.md @@ -370,9 +370,9 @@ app is only reachable through it — see ```text apps/api/ HTTP API + server-rendered UI (theme, charts, pages) apps/worker/ log watcher / importer / reingester -internal/parser/bflog/ Battlefield XML parser + vehicle-kill attribution +bflog/ Battlefield XML parser + vehicle-kill attribution (public: importable by other tools) internal/storage/ PostgreSQL ingestion, identity linking, analytics -internal/domain/ normalized event types +domain/ normalized event types (public) migrations/ schema (applied by setup.sh/update.sh, tracked in schema_migrations) fixtures/ parser fixtures deployments/ production + dev docker-compose stacks, systemd templates, backups diff --git a/apps/api/export.go b/apps/api/export.go index 83f20c9..acd48d6 100644 --- a/apps/api/export.go +++ b/apps/api/export.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "github.com/hootmeow/spawnpoint/internal/domain" + "github.com/hootmeow/spawnpoint/domain" ) // playerExport lets a player download their own stats — the self-serve diff --git a/apps/api/main.go b/apps/api/main.go index f8e8a22..eef148a 100644 --- a/apps/api/main.go +++ b/apps/api/main.go @@ -23,7 +23,7 @@ import ( _ "github.com/lib/pq" "github.com/hootmeow/spawnpoint/internal/notify" - "github.com/hootmeow/spawnpoint/internal/parser/bflog" + "github.com/hootmeow/spawnpoint/bflog" "github.com/hootmeow/spawnpoint/internal/storage/postgres" ) diff --git a/apps/api/player.go b/apps/api/player.go index 0a9f64f..f02f970 100644 --- a/apps/api/player.go +++ b/apps/api/player.go @@ -14,7 +14,7 @@ import ( "strings" "time" - "github.com/hootmeow/spawnpoint/internal/domain" + "github.com/hootmeow/spawnpoint/domain" ) type pairCountRow struct { diff --git a/apps/api/upload.go b/apps/api/upload.go index 77b2396..73fd104 100644 --- a/apps/api/upload.go +++ b/apps/api/upload.go @@ -16,7 +16,7 @@ import ( "time" "github.com/hootmeow/spawnpoint/internal/notify" - "github.com/hootmeow/spawnpoint/internal/parser/bflog" + "github.com/hootmeow/spawnpoint/bflog" "github.com/hootmeow/spawnpoint/internal/storage/postgres" ) diff --git a/apps/worker/main.go b/apps/worker/main.go index 1d16319..4daa471 100644 --- a/apps/worker/main.go +++ b/apps/worker/main.go @@ -22,7 +22,7 @@ import ( "github.com/hootmeow/spawnpoint/internal/gamespy" "github.com/hootmeow/spawnpoint/internal/notify" - "github.com/hootmeow/spawnpoint/internal/parser/bflog" + "github.com/hootmeow/spawnpoint/bflog" "github.com/hootmeow/spawnpoint/internal/storage/postgres" ) diff --git a/internal/parser/bflog/parser.go b/bflog/parser.go similarity index 99% rename from internal/parser/bflog/parser.go rename to bflog/parser.go index 9daca35..79b15c1 100644 --- a/internal/parser/bflog/parser.go +++ b/bflog/parser.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/hootmeow/spawnpoint/internal/domain" + "github.com/hootmeow/spawnpoint/domain" ) const battlefieldNamespace = "http://www.dice.se/xmlns/bf/1.1" diff --git a/internal/parser/bflog/parser_test.go b/bflog/parser_test.go similarity index 98% rename from internal/parser/bflog/parser_test.go rename to bflog/parser_test.go index ad9e48e..aca661b 100644 --- a/internal/parser/bflog/parser_test.go +++ b/bflog/parser_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/hootmeow/spawnpoint/internal/domain" + "github.com/hootmeow/spawnpoint/domain" ) func TestParseBasicBattlefieldLog(t *testing.T) { diff --git a/internal/domain/clantag.go b/domain/clantag.go similarity index 100% rename from internal/domain/clantag.go rename to domain/clantag.go diff --git a/internal/domain/clantag_test.go b/domain/clantag_test.go similarity index 100% rename from internal/domain/clantag_test.go rename to domain/clantag_test.go diff --git a/internal/domain/event.go b/domain/event.go similarity index 100% rename from internal/domain/event.go rename to domain/event.go diff --git a/internal/domain/medal.go b/domain/medal.go similarity index 100% rename from internal/domain/medal.go rename to domain/medal.go diff --git a/fixtures/README.md b/fixtures/README.md index 0806bf4..db4e3ce 100644 --- a/fixtures/README.md +++ b/fixtures/README.md @@ -9,7 +9,7 @@ fixtures/ ``` Both directories are currently empty placeholders — the parser's unit tests -(`internal/parser/bflog/parser_test.go`) use inline XML instead. If you have a +(`bflog/parser_test.go`) use inline XML instead. If you have a real round log you're comfortable sharing (nicknames and chat lines are visible in it, so sanitize first), a fixture-based compatibility test is a welcome contribution: diff --git a/internal/notify/round.go b/internal/notify/round.go index 1e6e207..d7cbab6 100644 --- a/internal/notify/round.go +++ b/internal/notify/round.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/hootmeow/spawnpoint/internal/domain" + "github.com/hootmeow/spawnpoint/domain" "github.com/hootmeow/spawnpoint/internal/storage/postgres" ) diff --git a/internal/storage/postgres/store.go b/internal/storage/postgres/store.go index 12fb24e..e6f31cc 100644 --- a/internal/storage/postgres/store.go +++ b/internal/storage/postgres/store.go @@ -19,7 +19,7 @@ import ( _ "github.com/lib/pq" - "github.com/hootmeow/spawnpoint/internal/domain" + "github.com/hootmeow/spawnpoint/domain" ) const (