From 05ca9fc9d7dc5ac76a5b0834149ccf5e5b95e56d Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 6 Jan 2026 15:31:48 +0100 Subject: [PATCH] Add Values functions to flat structs to map them to []interface for clickhouse --- clickhouse.go | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/clickhouse.go b/clickhouse.go index 655f910..9002b2c 100644 --- a/clickhouse.go +++ b/clickhouse.go @@ -6,9 +6,35 @@ import ( "strings" ) -// =============================================== -// CONVERSION FUNCTIONS -// =============================================== +// Values returns all fields in the order expected by ClickHouse INSERT +func (fk *FlatKillmail) Values() []interface{} { + return []interface{}{ + fk.KillmailID, + fk.KillmailTime, + fk.SolarSystemID, + fk.KillmailHash, + fk.VictimShipTypeID, + fk.VictimCharacterID, + fk.VictimCorporationID, + fk.VictimAllianceID, + fk.VictimDamageTaken, + fk.VictimPosX, + fk.VictimPosY, + fk.VictimPosZ, + fk.AttackerCount, + fk.TotalDamageDone, + fk.FinalBlowShipType, + fk.Attackers, + fk.Items, + } +} +func (fm *FlatModule) Values() []interface{} { + return []interface{}{ + fm.KillmailID, + fm.ItemTypeID, + string(fm.Slot), + } +} // FlattenKillmail converts the nested JSON structure to ClickHouse format func (k *Killmail) FlattenKillmail() (*FlatKillmail, []*FlatModule) {