Host clickhouse on linux
Doesn't work on windows something something fs permissions something something linux api Whatever. Works on linux
This commit is contained in:
51
db.go
51
db.go
@@ -55,11 +55,13 @@ func GetDB() (DB, error) {
|
||||
}
|
||||
|
||||
// ClickHouse connection - use HTTP interface on port 8123
|
||||
// Change "localhost" to your Linux host IP or hostname
|
||||
options := &clickhouse.Options{
|
||||
Addr: []string{"localhost:8123"},
|
||||
Addr: []string{"clickhouse.site.quack-lab.dev"}, // TODO: Change to your Linux host, e.g., "192.168.1.100:8123" or "clickhouse.example.com:8123"
|
||||
Auth: clickhouse.Auth{
|
||||
Database: "zkill",
|
||||
Username: "default",
|
||||
Password: "", // Set if you configure a password on Linux host
|
||||
},
|
||||
Protocol: clickhouse.HTTP,
|
||||
}
|
||||
@@ -188,8 +190,53 @@ func (db *DBWrapper) SaveKillmails(killmails []Killmail) error {
|
||||
flat := km.FlattenKillmail()
|
||||
modules := km.ExtractFittedModules()
|
||||
|
||||
// Convert attackers to slice of slices for ClickHouse Array(Tuple(...))
|
||||
attackersSlice := make([][]interface{}, len(flat.Attackers))
|
||||
for j, a := range flat.Attackers {
|
||||
attackersSlice[j] = []interface{}{
|
||||
a.CharacterID,
|
||||
a.CorporationID,
|
||||
a.AllianceID,
|
||||
a.ShipTypeID,
|
||||
a.WeaponTypeID,
|
||||
a.DamageDone,
|
||||
a.FinalBlow,
|
||||
a.SecurityStatus,
|
||||
}
|
||||
}
|
||||
|
||||
// Convert items to slice of slices
|
||||
itemsSlice := make([][]interface{}, len(flat.Items))
|
||||
for j, item := range flat.Items {
|
||||
itemsSlice[j] = []interface{}{
|
||||
item.Flag,
|
||||
item.ItemTypeID,
|
||||
item.QuantityDestroyed,
|
||||
item.QuantityDropped,
|
||||
item.Singleton,
|
||||
}
|
||||
}
|
||||
|
||||
// Append to flat_killmails batch
|
||||
if err := flatBatch.AppendStruct(flat); err != nil {
|
||||
if err := flatBatch.Append(
|
||||
flat.KillmailID,
|
||||
flat.KillmailTime,
|
||||
flat.SolarSystemID,
|
||||
flat.KillmailHash,
|
||||
flat.VictimShipTypeID,
|
||||
flat.VictimCharacterID,
|
||||
flat.VictimCorporationID,
|
||||
flat.VictimAllianceID,
|
||||
flat.VictimDamageTaken,
|
||||
flat.VictimPosX,
|
||||
flat.VictimPosY,
|
||||
flat.VictimPosZ,
|
||||
flat.AttackerCount,
|
||||
flat.TotalDamageDone,
|
||||
flat.FinalBlowShipType,
|
||||
attackersSlice,
|
||||
itemsSlice,
|
||||
); err != nil {
|
||||
return fmt.Errorf("failed to append flat killmail: %w", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user