photoprism/internal/entity/location_fixtures.go
Michael Mayer 2156afd85a File browser: Implement clipboard; refactor entities and fixtures #260
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-05-25 19:10:44 +02:00

119 lines
3.1 KiB
Go

package entity
import "time"
type LocationMap map[string]Location
func (m LocationMap) Get(name string) Location {
if result, ok := m[name]; ok {
return result
}
return UnknownLocation
}
func (m LocationMap) Pointer(name string) *Location {
if result, ok := m[name]; ok {
return &result
}
return &UnknownLocation
}
var LocationFixtures = LocationMap{
"mexico": {
LocUID: "85d1ea7d382c",
PlaceUID: PlaceFixtures.Get("mexico").PlaceUID,
LocName: "Adosada Platform",
LocCategory: "tourism",
Place: PlaceFixtures.Pointer("mexico"),
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"caravan park": {
LocUID: "1ef75a71a36c",
PlaceUID: "1ef75a71a36c",
Place: &Place{
PlaceUID: "1ef75a71a36",
LocLabel: "Mandeni, KwaZulu-Natal, South Africa",
LocCity: "Mandeni",
LocState: "KwaZulu-Natal",
LocCountry: "za",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
LocName: "Lobotes Caravan Park",
LocCategory: "camping",
LocSource: "manual",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"zinkwazi": {
LocUID: "1ef744d1e28c",
PlaceUID: PlaceFixtures.Get("zinkwazi").PlaceUID,
Place: PlaceFixtures.Pointer("zinkwazi"),
LocName: "Zinkwazi Beach",
LocCategory: "",
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"hassloch": {
LocUID: "1ef744d1e280",
PlaceUID: PlaceFixtures.Get("holidaypark").PlaceUID,
Place: PlaceFixtures.Pointer("holidaypark"),
LocName: "Holiday Park",
LocCategory: "",
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"emptyNameLongCity": {
LocUID: "1ef744d1e281",
PlaceUID: PlaceFixtures.Get("emptyNameLongCity").PlaceUID,
Place: PlaceFixtures.Pointer("emptyNameLongCity"),
LocName: "",
LocCategory: "",
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"emptyNameShortCity": {
LocUID: "1ef744d1e282",
PlaceUID: PlaceFixtures.Get("emptyNameShortCity").PlaceUID,
Place: PlaceFixtures.Pointer("emptyNameShortCity"),
LocName: "",
LocCategory: "",
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"veryLongLocName": {
LocUID: "1ef744d1e283",
PlaceUID: PlaceFixtures.Get("veryLongLocName").PlaceUID,
Place: PlaceFixtures.Pointer("veryLongLocName"),
LocName: "longlonglonglonglonglonglonglonglonglonglonglonglongName",
LocCategory: "",
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
"mediumLongLocName": {
LocUID: "1ef744d1e283",
PlaceUID: PlaceFixtures.Get("mediumLongLocName").PlaceUID,
Place: PlaceFixtures.Pointer("mediumLongLocName"),
LocName: "longlonglonglonglonglongName",
LocCategory: "",
LocSource: "places",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
}
// CreateLocationFixtures inserts known entities into the database for testing.
func CreateLocationFixtures() {
for _, entity := range LocationFixtures {
Db().Create(&entity)
}
}