2020-05-08 11:46:09 +02:00
|
|
|
package entity
|
|
|
|
|
2020-06-05 16:49:32 +02:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/pkg/s2"
|
|
|
|
)
|
2020-05-08 11:46:09 +02:00
|
|
|
|
2020-05-10 19:43:49 +02:00
|
|
|
type LocationMap map[string]Location
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-05-10 19:43:49 +02:00
|
|
|
var LocationFixtures = LocationMap{
|
2020-05-08 11:46:09 +02:00
|
|
|
"mexico": {
|
2020-06-05 16:49:32 +02:00
|
|
|
ID: s2.TokenPrefix+"85d1ea7d382c",
|
2020-05-29 12:56:24 +02:00
|
|
|
PlaceID: PlaceFixtures.Get("mexico").ID,
|
2020-05-08 11:46:09 +02:00
|
|
|
LocName: "Adosada Platform",
|
2020-05-29 12:21:17 +02:00
|
|
|
LocCategory: "botanical garden",
|
2020-05-25 19:10:44 +02:00
|
|
|
Place: PlaceFixtures.Pointer("mexico"),
|
2020-05-08 11:46:09 +02:00
|
|
|
LocSource: "places",
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
},
|
|
|
|
"caravan park": {
|
2020-06-05 16:49:32 +02:00
|
|
|
ID: s2.TokenPrefix+"1ef75a71a36c",
|
|
|
|
PlaceID: s2.TokenPrefix+"1ef75a71a36c",
|
2020-05-10 19:43:49 +02:00
|
|
|
Place: &Place{
|
2020-06-05 16:49:32 +02:00
|
|
|
ID: "x1ef75a71a36",
|
2020-05-10 19:43:49 +02:00
|
|
|
LocLabel: "Mandeni, KwaZulu-Natal, South Africa",
|
|
|
|
LocCity: "Mandeni",
|
|
|
|
LocState: "KwaZulu-Natal",
|
|
|
|
LocCountry: "za",
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
},
|
2020-05-08 11:46:09 +02:00
|
|
|
LocName: "Lobotes Caravan Park",
|
|
|
|
LocCategory: "camping",
|
|
|
|
LocSource: "manual",
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
},
|
|
|
|
"zinkwazi": {
|
2020-06-05 16:49:32 +02:00
|
|
|
ID: s2.TokenPrefix+"1ef744d1e28c",
|
2020-05-29 12:56:24 +02:00
|
|
|
PlaceID: PlaceFixtures.Get("zinkwazi").ID,
|
2020-05-10 19:43:49 +02:00
|
|
|
Place: PlaceFixtures.Pointer("zinkwazi"),
|
2020-05-08 11:46:09 +02:00
|
|
|
LocName: "Zinkwazi Beach",
|
2020-05-29 12:21:17 +02:00
|
|
|
LocCategory: "beach",
|
2020-05-08 11:46:09 +02:00
|
|
|
LocSource: "places",
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
},
|
2020-05-11 17:01:05 +02:00
|
|
|
"hassloch": {
|
2020-06-05 16:49:32 +02:00
|
|
|
ID: s2.TokenPrefix+"1ef744d1e280",
|
2020-05-29 12:56:24 +02:00
|
|
|
PlaceID: PlaceFixtures.Get("holidaypark").ID,
|
2020-05-11 17:01:05 +02:00
|
|
|
Place: PlaceFixtures.Pointer("holidaypark"),
|
|
|
|
LocName: "Holiday Park",
|
2020-05-29 12:21:17 +02:00
|
|
|
LocCategory: "park",
|
2020-05-11 17:01:05 +02:00
|
|
|
LocSource: "places",
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
},
|
|
|
|
"emptyNameLongCity": {
|
2020-06-05 16:49:32 +02:00
|
|
|
ID: s2.TokenPrefix+"1ef744d1e281",
|
2020-05-29 12:56:24 +02:00
|
|
|
PlaceID: PlaceFixtures.Get("emptyNameLongCity").ID,
|
2020-05-11 17:01:05 +02:00
|
|
|
Place: PlaceFixtures.Pointer("emptyNameLongCity"),
|
|
|
|
LocName: "",
|
2020-05-29 12:21:17 +02:00
|
|
|
LocCategory: "botanical garden",
|
2020-05-11 17:01:05 +02:00
|
|
|
LocSource: "places",
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
},
|
|
|
|
"emptyNameShortCity": {
|
2020-06-05 16:49:32 +02:00
|
|
|
ID: s2.TokenPrefix+"1ef744d1e282",
|
2020-05-29 12:56:24 +02:00
|
|
|
PlaceID: PlaceFixtures.Get("emptyNameShortCity").ID,
|
2020-05-11 17:01:05 +02:00
|
|
|
Place: PlaceFixtures.Pointer("emptyNameShortCity"),
|
|
|
|
LocName: "",
|
2020-05-29 12:21:17 +02:00
|
|
|
LocCategory: "botanical garden",
|
2020-05-11 17:01:05 +02:00
|
|
|
LocSource: "places",
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
},
|
|
|
|
"veryLongLocName": {
|
2020-06-05 16:49:32 +02:00
|
|
|
ID: s2.TokenPrefix+"1ef744d1e283",
|
2020-05-29 12:56:24 +02:00
|
|
|
PlaceID: PlaceFixtures.Get("veryLongLocName").ID,
|
2020-05-11 17:01:05 +02:00
|
|
|
Place: PlaceFixtures.Pointer("veryLongLocName"),
|
|
|
|
LocName: "longlonglonglonglonglonglonglonglonglonglonglonglongName",
|
2020-05-29 12:21:17 +02:00
|
|
|
LocCategory: "cape",
|
2020-05-11 17:01:05 +02:00
|
|
|
LocSource: "places",
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
},
|
|
|
|
"mediumLongLocName": {
|
2020-06-05 16:49:32 +02:00
|
|
|
ID: s2.TokenPrefix+"1ef744d1e283",
|
2020-05-29 12:56:24 +02:00
|
|
|
PlaceID: PlaceFixtures.Get("mediumLongLocName").ID,
|
2020-05-11 17:01:05 +02:00
|
|
|
Place: PlaceFixtures.Pointer("mediumLongLocName"),
|
|
|
|
LocName: "longlonglonglonglonglongName",
|
2020-05-29 12:21:17 +02:00
|
|
|
LocCategory: "botanical garden",
|
2020-05-11 17:01:05 +02:00
|
|
|
LocSource: "places",
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
},
|
2020-05-08 11:46:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateLocationFixtures inserts known entities into the database for testing.
|
|
|
|
func CreateLocationFixtures() {
|
|
|
|
for _, entity := range LocationFixtures {
|
|
|
|
Db().Create(&entity)
|
|
|
|
}
|
|
|
|
}
|