2020-04-30 14:32:48 +02:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2020-05-10 19:43:49 +02:00
|
|
|
type LabelMap map[string]Label
|
|
|
|
|
|
|
|
func (m LabelMap) Get(name string) Label {
|
|
|
|
if result, ok := m[name]; ok {
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
return *NewLabel(name, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m LabelMap) Pointer(name string) *Label {
|
|
|
|
if result, ok := m[name]; ok {
|
|
|
|
return &result
|
|
|
|
}
|
|
|
|
|
|
|
|
return NewLabel(name, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m LabelMap) PhotoLabel(photoId uint, labelName string, uncertainty int, source string) PhotoLabel {
|
|
|
|
label := m.Get(labelName)
|
|
|
|
|
|
|
|
photoLabel := NewPhotoLabel(photoId, label.ID, uncertainty, source)
|
|
|
|
photoLabel.Label = &label
|
|
|
|
|
|
|
|
return *photoLabel
|
|
|
|
}
|
|
|
|
|
|
|
|
var LabelFixtures = LabelMap{
|
2020-04-30 14:32:48 +02:00
|
|
|
"landscape": {
|
|
|
|
ID: 1000000,
|
2020-05-23 20:58:58 +02:00
|
|
|
LabelUID: "lt9k3pw1wowuy3c2",
|
2020-04-30 14:32:48 +02:00
|
|
|
LabelSlug: "landscape",
|
|
|
|
CustomSlug: "landscape",
|
|
|
|
LabelName: "Landscape",
|
|
|
|
LabelPriority: 0,
|
|
|
|
LabelFavorite: true,
|
|
|
|
LabelDescription: "",
|
|
|
|
LabelNotes: "",
|
2020-05-10 19:43:49 +02:00
|
|
|
PhotoCount: 1,
|
2020-04-30 14:32:48 +02:00
|
|
|
LabelCategories: []*Label{},
|
|
|
|
Links: []Link{},
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
DeletedAt: nil,
|
|
|
|
New: false,
|
|
|
|
},
|
2020-04-30 17:26:21 +02:00
|
|
|
"flower": {
|
|
|
|
ID: 1000001,
|
2020-05-23 20:58:58 +02:00
|
|
|
LabelUID: "lt9k3pw1wowuy3c3",
|
2020-04-30 17:26:21 +02:00
|
|
|
LabelSlug: "flower",
|
|
|
|
CustomSlug: "flower",
|
|
|
|
LabelName: "Flower",
|
|
|
|
LabelPriority: 1,
|
|
|
|
LabelFavorite: true,
|
|
|
|
LabelDescription: "",
|
|
|
|
LabelNotes: "",
|
2020-05-10 19:43:49 +02:00
|
|
|
PhotoCount: 2,
|
2020-04-30 17:26:21 +02:00
|
|
|
LabelCategories: []*Label{},
|
|
|
|
Links: []Link{},
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
DeletedAt: nil,
|
|
|
|
New: false,
|
|
|
|
},
|
|
|
|
"cake": {
|
|
|
|
ID: 1000002,
|
2020-05-23 20:58:58 +02:00
|
|
|
LabelUID: "lt9k3pw1wowuy3c4",
|
2020-04-30 17:26:21 +02:00
|
|
|
LabelSlug: "cake",
|
|
|
|
CustomSlug: "kuchen",
|
|
|
|
LabelName: "Cake",
|
|
|
|
LabelPriority: 5,
|
|
|
|
LabelFavorite: false,
|
|
|
|
LabelDescription: "",
|
|
|
|
LabelNotes: "",
|
2020-05-10 19:43:49 +02:00
|
|
|
PhotoCount: 3,
|
2020-04-30 17:26:21 +02:00
|
|
|
LabelCategories: []*Label{},
|
|
|
|
Links: []Link{},
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
DeletedAt: nil,
|
|
|
|
New: false,
|
|
|
|
},
|
|
|
|
"cow": {
|
|
|
|
ID: 1000003,
|
2020-05-23 20:58:58 +02:00
|
|
|
LabelUID: "lt9k3pw1wowuy3c5",
|
2020-04-30 17:26:21 +02:00
|
|
|
LabelSlug: "cow",
|
|
|
|
CustomSlug: "kuh",
|
2020-05-01 14:13:59 +02:00
|
|
|
LabelName: "COW",
|
2020-04-30 17:26:21 +02:00
|
|
|
LabelPriority: -1,
|
|
|
|
LabelFavorite: true,
|
|
|
|
LabelDescription: "",
|
|
|
|
LabelNotes: "",
|
2020-05-10 19:43:49 +02:00
|
|
|
PhotoCount: 4,
|
2020-04-30 17:26:21 +02:00
|
|
|
LabelCategories: []*Label{},
|
|
|
|
Links: []Link{},
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
DeletedAt: nil,
|
|
|
|
New: false,
|
|
|
|
},
|
2020-05-03 17:19:20 +02:00
|
|
|
"batchdelete": {
|
|
|
|
ID: 1000004,
|
2020-05-23 20:58:58 +02:00
|
|
|
LabelUID: "lt9k3pw1wowuy3c6",
|
2020-05-03 17:19:20 +02:00
|
|
|
LabelSlug: "batchdelete",
|
|
|
|
CustomSlug: "batchDelete",
|
|
|
|
LabelName: "BatchDelete",
|
|
|
|
LabelPriority: 1,
|
|
|
|
LabelFavorite: true,
|
|
|
|
LabelDescription: "",
|
|
|
|
LabelNotes: "",
|
2020-05-10 19:43:49 +02:00
|
|
|
PhotoCount: 5,
|
2020-05-03 17:19:20 +02:00
|
|
|
LabelCategories: []*Label{},
|
|
|
|
Links: []Link{},
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
DeletedAt: nil,
|
|
|
|
New: false,
|
|
|
|
},
|
2020-05-04 16:02:49 +02:00
|
|
|
"updateLabel": {
|
|
|
|
ID: 1000005,
|
2020-05-23 20:58:58 +02:00
|
|
|
LabelUID: "lt9k3pw1wowuy3c7",
|
2020-05-04 16:02:49 +02:00
|
|
|
LabelSlug: "updatelabel",
|
|
|
|
CustomSlug: "updateLabel",
|
|
|
|
LabelName: "updateLabel",
|
|
|
|
LabelPriority: 2,
|
|
|
|
LabelFavorite: false,
|
|
|
|
LabelDescription: "",
|
|
|
|
LabelNotes: "",
|
2020-05-10 19:43:49 +02:00
|
|
|
PhotoCount: 1,
|
2020-05-04 16:02:49 +02:00
|
|
|
LabelCategories: []*Label{},
|
|
|
|
Links: []Link{},
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
DeletedAt: nil,
|
|
|
|
New: false,
|
|
|
|
},
|
2020-05-05 09:28:30 +02:00
|
|
|
"updatePhotoLabel": {
|
|
|
|
ID: 1000006,
|
2020-05-23 20:58:58 +02:00
|
|
|
LabelUID: "lt9k3pw1wowuy3c8",
|
2020-05-05 09:28:30 +02:00
|
|
|
LabelSlug: "updatephotolabel",
|
|
|
|
CustomSlug: "updateLabelPhoto",
|
|
|
|
LabelName: "updatePhotoLabel",
|
|
|
|
LabelPriority: 2,
|
|
|
|
LabelFavorite: false,
|
|
|
|
LabelDescription: "",
|
|
|
|
LabelNotes: "",
|
2020-05-10 19:43:49 +02:00
|
|
|
PhotoCount: 1,
|
2020-05-05 09:28:30 +02:00
|
|
|
LabelCategories: []*Label{},
|
|
|
|
Links: []Link{},
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
DeletedAt: nil,
|
|
|
|
New: false,
|
|
|
|
},
|
2020-05-14 14:17:12 +02:00
|
|
|
"likeLabel": {
|
|
|
|
ID: 1000007,
|
2020-05-23 20:58:58 +02:00
|
|
|
LabelUID: "lt9k3pw1wowuy3c9",
|
2020-05-14 14:17:12 +02:00
|
|
|
LabelSlug: "likeLabel",
|
|
|
|
CustomSlug: "likeLabel",
|
|
|
|
LabelName: "likeLabel",
|
|
|
|
LabelPriority: 3,
|
|
|
|
LabelFavorite: false,
|
|
|
|
LabelDescription: "",
|
|
|
|
LabelNotes: "",
|
|
|
|
PhotoCount: 1,
|
|
|
|
LabelCategories: []*Label{},
|
|
|
|
Links: []Link{},
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
DeletedAt: nil,
|
|
|
|
New: false,
|
|
|
|
},
|
2020-05-25 19:10:44 +02:00
|
|
|
"no-jpeg": {
|
|
|
|
ID: 1000008,
|
|
|
|
LabelUID: "lt9k3aa1wowuy3c5",
|
|
|
|
LabelSlug: "no-jpeg",
|
|
|
|
CustomSlug: "no-jpeg",
|
|
|
|
LabelName: "NO JPEG",
|
|
|
|
LabelPriority: -1,
|
|
|
|
LabelFavorite: false,
|
|
|
|
LabelDescription: "",
|
|
|
|
LabelNotes: "",
|
|
|
|
PhotoCount: 4,
|
|
|
|
LabelCategories: []*Label{},
|
|
|
|
Links: []Link{},
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
UpdatedAt: time.Now(),
|
|
|
|
DeletedAt: nil,
|
|
|
|
New: false,
|
|
|
|
},
|
2020-04-30 14:32:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateLabelFixtures inserts known entities into the database for testing.
|
2020-04-30 20:07:03 +02:00
|
|
|
func CreateLabelFixtures() {
|
2020-04-30 14:32:48 +02:00
|
|
|
for _, entity := range LabelFixtures {
|
2020-04-30 20:07:03 +02:00
|
|
|
Db().Create(&entity)
|
2020-04-30 14:32:48 +02:00
|
|
|
}
|
|
|
|
}
|