Files
zkill-susser/types.go

157 lines
4.4 KiB
Go

package main
import "time"
type Killmail struct {
Attackers []Attacker `json:"attackers"`
KillmailID int64 `json:"killmail_id"`
KillmailTime time.Time `json:"killmail_time"`
SolarSystemID int64 `json:"solar_system_id"`
Victim Victim `json:"victim"`
KillmailHash string `json:"killmail_hash"`
HTTPLastModified time.Time `json:"http_last_modified"`
}
type Attacker struct {
AllianceID int64 `json:"alliance_id"`
CharacterID int64 `json:"character_id"`
CorporationID int64 `json:"corporation_id"`
DamageDone int64 `json:"damage_done"`
FinalBlow bool `json:"final_blow"`
SecurityStatus float64 `json:"security_status"`
ShipTypeID int64 `json:"ship_type_id"`
WeaponTypeID int64 `json:"weapon_type_id"`
}
type Victim struct {
AllianceID int64 `json:"alliance_id"`
CharacterID int64 `json:"character_id"`
CorporationID int64 `json:"corporation_id"`
DamageTaken int64 `json:"damage_taken"`
Items []Item `json:"items"`
Position Position `json:"position"`
ShipTypeID int64 `json:"ship_type_id"`
}
type Item struct {
Flag int64 `json:"flag"`
ItemTypeID int64 `json:"item_type_id"`
QuantityDestroyed *int64 `json:"quantity_destroyed,omitempty"`
Singleton int64 `json:"singleton"`
QuantityDropped *int64 `json:"quantity_dropped,omitempty"`
}
type Position struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Z float64 `json:"z"`
}
// Helper functions
func boolToUint8(b bool) uint8 {
if b {
return 1
}
return 0
}
func derefInt64(ptr *int64) int64 {
if ptr == nil {
return 0
}
return *ptr
}
type ModuleSlot string
var (
ModuleSlotLow ModuleSlot = "Low"
ModuleSlotMid ModuleSlot = "Mid"
ModuleSlotHigh ModuleSlot = "High"
ModuleSlotRig ModuleSlot = "Rig"
ModuleSlotSubsystem ModuleSlot = "Subsystem"
ModuleSlotDrone ModuleSlot = "Drone"
ModuleSlotOther ModuleSlot = "Other"
)
// region Other various types
type QueryParams struct {
Ship int64
Systems []int64
Modules []int64
Groups []int64
KillmailLimit int
}
type ModuleStatsData struct {
KillmailIDs []int64
}
type ComprehensiveStatsData struct {
QueryParams
KillmailLimit int
}
// CacheEntry stores both statistics (JSON) and images (blobs) in unified cache
// For 404s, we store a special marker: []byte{0xFF, 0xFE, 0xFD} (NOT_FOUND_MARKER)
type CacheEntry struct {
Key string `gorm:"primaryKey"`
Data []byte `gorm:"type:BLOB;not null"`
CreatedAt time.Time `gorm:"not null;index"`
}
var notFoundMarker = []byte{0xFF, 0xFE, 0xFD} // Special marker for cached 404s
func (CacheEntry) TableName() string {
return "cache_entries"
}
type FitStatistics struct {
TotalKillmails int64
ShipBreakdown map[int64]int64
SystemBreakdown map[int64]int64
HighSlotModules map[int32]int64
MidSlotModules map[int32]int64
LowSlotModules map[int32]int64
Rigs map[int32]int64
Drones map[int32]int64
KillmailIDs []int64
}
type Character struct {
AllianceID int64 `json:"alliance_id"`
Birthday time.Time `json:"birthday"`
BloodlineID int64 `json:"bloodline_id"`
CorporationID int64 `json:"corporation_id"`
Description string `json:"description"`
Gender string `json:"gender"`
Name string `json:"name"`
RaceID int64 `json:"race_id"`
SecurityStatus float64 `json:"security_status"`
}
type Corporation struct {
AllianceID int64 `json:"alliance_id"`
CeoID int64 `json:"ceo_id"`
CreatorID int64 `json:"creator_id"`
DateFounded time.Time `json:"date_founded"`
Description string `json:"description"`
HomeStationID int64 `json:"home_station_id"`
MemberCount int64 `json:"member_count"`
Name string `json:"name"`
Shares int64 `json:"shares"`
TaxRate float64 `json:"tax_rate"`
Ticker string `json:"ticker"`
URL string `json:"url"`
WarEligible bool `json:"war_eligible"`
}
type Alliance struct {
CreatorCorporationID int64 `json:"creator_corporation_id"`
CreatorID int64 `json:"creator_id"`
DateFounded time.Time `json:"date_founded"`
ExecutorCorporationID int64 `json:"executor_corporation_id"`
Name string `json:"name"`
Ticker string `json:"ticker"`
}