Documentation
¶
Overview ¶
Package fw imports faction warfare state from ESI.
Two datasets with different shapes: system occupancy, which is current state plus a history of who took what from whom, and faction statistics, which are a snapshot with no history at all.
The occupancy importer is written the way it is because of a production bug it exists to avoid. The TypeScript FwUpdateCronJob builds its upsert as `set: { owner_faction_id: fwSystems.owner_faction_id, ... }`, which renders as `SET owner_faction_id = fw_systems.owner_faction_id` — every column assigned to itself. The row is touched and nothing changes, so the current state never advances, and every run therefore re-detects flips that happened months ago and appends them to the history again. Production shows the result: fw_systems.updated_at frozen at 2026-04-11 while fw_system_history holds 88,376 rows describing 53 actual transitions, one of them recorded 5,079 times, still growing at about 1,400 rows a day.
This is the same bug as SovereigntyCronJob's, and the same fix: compare against what is stored, write only what moved, and prove it with a test that applies one snapshot twice.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PurgeHistoryDuplicates ¶
PurgeHistoryDuplicates removes the artefacts the TypeScript cron left behind.
Consecutive identical transitions for one system are not events — they are the same flip re-detected because the current-state table never advanced. Only the first of each run survives.
Offered as a maintenance operation rather than run automatically: it deletes tens of thousands of rows, and that should be somebody's deliberate decision.
Types ¶
type Result ¶
type Result struct {
// Seen is how many systems ESI described.
Seen int64 `json:"seen"`
// Rows is how many current-state rows actually changed.
Rows int64 `json:"rows"`
// Flips is how many genuine occupier changes were recorded.
Flips int64 `json:"flips"`
}
Result reports one import.
type StatsResult ¶
type StatsResult struct {
Factions int64 `json:"factions"`
Leaderboards int64 `json:"leaderboards"`
}
StatsResult reports one stats import.
func ImportStats ¶
ImportStats refreshes faction standings and the three leaderboards.