Implement fetching items for killmail victims
This commit is contained in:
36
db.go
36
db.go
@@ -76,7 +76,36 @@ func (db *DBWrapper) QueryFits(params QueryParams) ([]Fit, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
flog.Info("Ship type: %v", shipType)
|
||||
flog.Trace("Found ship type for %s at %d", shipType.TypeName, shipType.TypeID)
|
||||
flog.Dump("Ship type", shipType)
|
||||
|
||||
victims := []Victim{}
|
||||
result := db.db.Table("public.zkill_victims").
|
||||
Where("ship_type_id = ?", shipType.TypeID).
|
||||
Find(&victims)
|
||||
if result.Error != nil {
|
||||
flog.Error("Failed to find killmails: %v", result.Error)
|
||||
return nil, result.Error
|
||||
}
|
||||
flog.Debug("Found %d killmails", result.RowsAffected)
|
||||
|
||||
// TODO: DEBUG!
|
||||
victims = victims[:10]
|
||||
|
||||
items := []Item{}
|
||||
for _, victim := range victims {
|
||||
vlog := flog.WithPrefix(fmt.Sprintf("victim %d", victim.ID))
|
||||
vlog.Debug("Finding items")
|
||||
result = db.db.Table("public.zkill_items").
|
||||
Where("victim_id = ?", victim.ID).
|
||||
Find(&items)
|
||||
if result.Error != nil {
|
||||
vlog.Error("Failed to find items: %v", result.Error)
|
||||
return nil, result.Error
|
||||
}
|
||||
vlog.Debug("Found %d items", result.RowsAffected)
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -84,10 +113,13 @@ func (db *DBWrapper) ShipTypeFind(name string) (*models.InvType, error) {
|
||||
flog := logger.Default.WithPrefix("ShipTypeFind").WithPrefix(name)
|
||||
shipType := &models.InvType{}
|
||||
flog.Debug("Finding ship type")
|
||||
result := db.db.Table("evesde.invTypes").Where("\"typeName\" like ?", "%"+name+"%").First(&shipType)
|
||||
result := db.db.Table("evesde.invTypes").
|
||||
Where("LOWER(\"typeName\") LIKE LOWER(?)", "%"+name+"%").
|
||||
First(&shipType)
|
||||
if result.Error != nil {
|
||||
flog.Error("Failed to find ship type: %v", result.Error)
|
||||
return nil, result.Error
|
||||
}
|
||||
flog.Debug("Found %d records", result.RowsAffected)
|
||||
return shipType, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user