feat(go, ts): add system-region mapping and highlight functionality
This commit is contained in:
22
app.go
22
app.go
@@ -138,3 +138,25 @@ func (a *App) GetCharacterLocations() ([]CharacterLocation, error) {
|
||||
defer cancel()
|
||||
return a.ssi.GetCharacterLocations(ctx)
|
||||
}
|
||||
|
||||
// SystemRegion holds system + region names from local DB
|
||||
type SystemRegion struct {
|
||||
System string `json:"system"`
|
||||
Region string `json:"region"`
|
||||
}
|
||||
|
||||
// ListSystemsWithRegions returns all solar system names and their regions from the local SQLite DB
|
||||
func (a *App) ListSystemsWithRegions() ([]SystemRegion, error) {
|
||||
if a.ssi == nil || a.ssi.db == nil {
|
||||
return nil, errors.New("db not initialised")
|
||||
}
|
||||
var rows []SystemRegion
|
||||
// mapSolarSystems has regionID; mapRegions has regionName
|
||||
q := `SELECT s.solarSystemName AS system, r.regionName AS region
|
||||
FROM mapSolarSystems s
|
||||
JOIN mapRegions r ON r.regionID = s.regionID`
|
||||
if err := a.ssi.db.Raw(q).Scan(&rows).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user