Merge branch 'develop'

This commit is contained in:
Michael Mayer 2019-12-19 12:26:08 +01:00
commit e1c3bac244
14 changed files with 217 additions and 247 deletions

View file

@ -3,8 +3,6 @@ cat:
priority: 5 priority: 5
categories: categories:
- animal - animal
- kitty
- mammal
tabby cat: tabby cat:
see: cat see: cat
@ -23,10 +21,7 @@ tiger cat:
categories: categories:
- cat - cat
- tiger - tiger
- stripes
- animal - animal
- kitty
- mammal
wild cat: wild cat:
priority: 5 priority: 5
@ -34,7 +29,6 @@ wild cat:
categories: categories:
- cat - cat
- animal - animal
- mammal
- wildlife - wildlife
lynx: lynx:
@ -200,6 +194,7 @@ ship:
solar dish: solar dish:
threshold: 0.5 threshold: 0.5
priority: -1
grasshopper: grasshopper:
label: grasshopper label: grasshopper
@ -229,8 +224,6 @@ windsor tie:
chainlink fence: chainlink fence:
label: outdoor label: outdoor
priority: -1 priority: -1
categories:
- fence
mitten: mitten:
label: unknown label: unknown
@ -305,7 +298,7 @@ ostrich:
bird: bird:
label: bird label: bird
threshold: 0.25 threshold: 0.3
categories: categories:
- animal - animal
@ -387,23 +380,19 @@ axolotl:
- amphibians - amphibians
- animal - animal
bullfrog: frog:
label: frog
categories: categories:
- amphibians
- animal - animal
- frog
bullfrog:
see: frog
tree frog: tree frog:
categories: see: frog
- amphibians
- animal
- frog
tailed frog: tailed frog:
categories: see: frog
- amphibians
- animal
- frog
turtle: turtle:
label: turtle label: turtle
@ -439,6 +428,7 @@ african chameleon:
categories: categories:
- reptile - reptile
- animal - animal
- lizard
american chameleon: american chameleon:
see: african chameleon see: african chameleon
@ -473,12 +463,11 @@ green lizard:
see: lizard see: lizard
komodo dragon: komodo dragon:
categories: see: lizard
- reptile
- animal
african crocodile: african crocodile:
label: crocodile label: crocodile
threshold: 0.25
categories: categories:
- reptile - reptile
- animal - animal
@ -573,46 +562,32 @@ scorpion:
- spider - spider
- insect - insect
black and gold garden spider: spider:
label: spider
categories: categories:
- animal - animal
- spider
- insect black and gold garden spider:
see: spider
barn spider: barn spider:
categories: see: spider
- animal
- spider
- insect
garden spider: garden spider:
categories: see: spider
- animal
- spider
- insect
black widow: black widow:
categories: see: spider
- animal
- spider
- insect
tarantula: tarantula:
categories: see: spider
- animal
- spider
- insect
wolf spider: wolf spider:
categories: see: spider
- animal
- spider
- insect
centipede: centipede:
categories: categories:
- animal - animal
- insect
black grouse: black grouse:
threshold: 0.3 threshold: 0.3
@ -649,10 +624,10 @@ peacock:
- bird - bird
quail: quail:
label: bird
threshold: 0.3 threshold: 0.3
categories: categories:
- animal - animal
- bird
partridge: partridge:
threshold: 0.3 threshold: 0.3
@ -706,11 +681,11 @@ toucan:
- bird - bird
drake: drake:
label: duck
threshold: 0.3 threshold: 0.3
categories: categories:
- animal - animal
- bird - bird
- duck
red-breasted merganser: red-breasted merganser:
label: duck label: duck
@ -736,7 +711,7 @@ echidna:
- animal - animal
platypus: platypus:
threshold: 0.2 threshold: 0.3
categories: categories:
- animal - animal
@ -804,51 +779,48 @@ chambered nautilus:
- animal - animal
- slug - slug
dungeness crab: crab:
label: crab
categories: categories:
- animal - animal
- crab
dungeness crab:
see: crab
rock crab: rock crab:
categories: see: crab
- animal
- crab
fiddler crab: fiddler crab:
categories: see: crab
- animal
- crab
king crab: king crab:
see: crab
hermit crab:
see: crab
lobster:
label: lobster
categories: categories:
- animal - animal
- crab - food
- water
american lobster: american lobster:
categories: see: lobster
- animal
- crab
spiny lobster: spiny lobster:
categories: see: lobster
- animal
- crab
crayfish: crayfish:
categories: categories:
- water - water
- animal - animal
- crab - lobster
hermit crab:
categories:
- animal
- crab
isopod: isopod:
categories: categories:
- animal - animal
- insect
white stork: white stork:
label: storck label: storck
@ -908,14 +880,10 @@ redshank:
- nature - nature
dowitcher: dowitcher:
categories: see: bird
- animal
- bird
oystercatcher: oystercatcher:
categories: see: bird
- animal
- bird
pelican: pelican:
categories: categories:
@ -933,17 +901,17 @@ albatross:
- animal - animal
- bird - bird
grey whale: whale:
label: whale
categories: categories:
- animal - animal
- whale - water
- mammal
grey whale:
see: whale
killer whale: killer whale:
categories: see: whale
- animal
- whale
- mammal
dugong: dugong:
categories: categories:
@ -959,7 +927,6 @@ dog:
categories: categories:
- animal - animal
- puppy - puppy
- mammal
chihuahua dog: chihuahua dog:
see: dog see: dog
@ -1349,45 +1316,41 @@ African hunting dog:
hyena: hyena:
see: dog see: dog
red fox: fox:
label: fox
threshold: 0.3
categories: categories:
- fox
- animal - animal
red fox:
see: fox
kit fox: kit fox:
categories: see: fox
- fox
- animal
Arctic fox: arctic fox:
categories: see: fox
- fox
- animal
rgrey fox: grey fox:
see: fox
bear:
label: bear
threshold: 0.3
categories: categories:
- fox
- animal - animal
brown bear: brown bear:
categories: see: bear
- animal
- bear
American black bear: american black bear:
categories: see: bear
- animal
- bear
ice bear: ice bear:
categories: see: bear
- animal
- bear
sloth bear: sloth bear:
categories: see: bear
- animal
- bear
mongoose: mongoose:
categories: categories:
@ -1397,91 +1360,82 @@ meerkat:
categories: categories:
- animal - animal
tiger beetle: beetle:
label: beetle
categories: categories:
- animal - animal
- beetle
- insect tiger beetle:
see: beetle
ladybug: ladybug:
categories: see: beetle
- animal
- beetle
- insect
ground beetle: ground beetle:
categories: see: beetle
- animal
- beetle
- insect
long-horned beetle: long-horned beetle:
categories: see: beetle
- animal
- beetle
- insect
leaf beetle: leaf beetle:
categories: see: beetle
- animal
- beetle
- insect
dung beetle: dung beetle:
categories: categories:
- animal - animal
- beetle - beetle
- insect
rhinoceros beetle: rhinoceros beetle:
categories: see: beetle
- animal
- beetle
- insect
weevil: weevil:
categories: see: beetle
- animal
- beetle
- insect
fly: fly:
threshold: 0.3
categories: categories:
- animal - animal
- insect
bee: bee:
threshold: 0.3
categories: categories:
- animal - animal
- insect
apiary: apiary:
label: beehive
threshold: 0.3
priority: -1 priority: -1
ant: ant:
threshold: 0.3
categories: categories:
- animal - animal
- insect - insect
walking stick: walking stick:
threshold: 0.3
priority: -1 priority: -1
cockroach: cockroach:
threshold: 0.3
categories: categories:
- animal - animal
- insect - insect
mantis: mantis:
threshold: 0.3
categories: categories:
- animal - animal
- insect - insect
cicada: cicada:
threshold: 0.3
categories: categories:
- animal - animal
- insect - insect
leafhopper: leafhopper:
threshold: 0.3
categories: categories:
- animal - animal
- insect - insect
@ -1501,43 +1455,31 @@ damselfly:
- animal - animal
- insect - insect
admiral: butterfly:
label: butterfly
categories: categories:
- animal - animal
- insect
- butterfly admiral:
see: butterfly
ringlet: ringlet:
categories: see: butterfly
- animal
- insect
- butterfly
monarch: monarch:
categories: see: butterfly
- animal
- insect
- butterfly
cabbage butterfly: cabbage butterfly:
categories: see: butterfly
- animal
- insect
- butterfly
sulphur butterfly: sulphur butterfly:
categories: see: butterfly
- animal
- insect
- butterfly
lycaenid: lycaenid:
categories: see: butterfly
- animal
- insect
- butterfly
starfish: starfish:
threshold: 0.5
categories: categories:
- water - water
- sea - sea
@ -1610,7 +1552,6 @@ sorrel:
zebra: zebra:
categories: categories:
- animal - animal
- mammal
- wildlife - wildlife
hog: hog:
@ -1618,19 +1559,16 @@ hog:
categories: categories:
- animal - animal
- pig - pig
- mammal
wild boar: wild boar:
threshold: 0.66 threshold: 0.66
categories: categories:
- animal - animal
- mammal
warthog: warthog:
threshold: 0.66 threshold: 0.66
categories: categories:
- animal - animal
- mammal
- wildlife - wildlife
hippopotamus: hippopotamus:
@ -1644,19 +1582,16 @@ ox:
threshold: 0.2 threshold: 0.2
categories: categories:
- animal - animal
- mammal
- farm - farm
water buffalo: water buffalo:
categories: categories:
- animal - animal
- mammal
- farm - farm
bison: bison:
categories: categories:
- animal - animal
- mammal
ram: ram:
label: sheep label: sheep
@ -1664,43 +1599,36 @@ ram:
categories: categories:
- farm - farm
- animal - animal
- mammal
bighorn: bighorn:
categories: categories:
- animal - animal
- mammal
ibex: ibex:
categories: categories:
- animal - animal
- mammal
hartebeest: hartebeest:
threshold: 0.4 threshold: 0.4
categories: categories:
- animal - animal
- mammal
impala: impala:
threshold: 0.4 threshold: 0.4
categories: categories:
- animal - animal
- mammal
- wildlife - wildlife
gazelle: gazelle:
threshold: 0.4 threshold: 0.4
categories: categories:
- animal - animal
- mammal
- wildlife - wildlife
llama: llama:
threshold: 0.4 threshold: 0.4
categories: categories:
- animal - animal
- mammal
weasel: weasel:
threshold: 0.4 threshold: 0.4
@ -1725,7 +1653,6 @@ otter:
threshold: 0.4 threshold: 0.4
categories: categories:
- animal - animal
- mammal
skunk: skunk:
threshold: 0.4 threshold: 0.4
@ -1736,7 +1663,6 @@ badger:
threshold: 0.4 threshold: 0.4
categories: categories:
- animal - animal
- mammal
armadillo: armadillo:
categories: categories:
@ -1751,7 +1677,6 @@ ape:
priority: 2 priority: 2
categories: categories:
- animal - animal
- mammal
orangutan: orangutan:
see: ape see: ape
@ -1770,7 +1695,6 @@ monkey:
priority: 2 priority: 2
categories: categories:
- animal - animal
- mammal
siamang: siamang:
see: monkey see: monkey
@ -1828,12 +1752,11 @@ fossa:
see: cat see: cat
indian elephant: indian elephant:
label: elephant
priority: 2 priority: 2
threshold: 0.47 threshold: 0.47
categories: categories:
- animal - animal
- elephant
- mammal
- wildlife - wildlife
african elephant: african elephant:
@ -1842,7 +1765,6 @@ african elephant:
categories: categories:
- animal - animal
- elephant - elephant
- mammal
- wildlife - wildlife
tusker: tusker:
@ -1851,14 +1773,12 @@ tusker:
threshold: 0.3 threshold: 0.3
categories: categories:
- animal - animal
- mammal
panda: panda:
label: panda label: panda
priority: 2 priority: 2
categories: categories:
- animal - animal
- mammal
lesser panda: lesser panda:
see: panda see: panda
@ -1902,8 +1822,8 @@ puffer:
see: fish see: fish
instrument: instrument:
threshold: 0.5
categories: categories:
- instrument
- music - music
- entertainment - entertainment
@ -2103,6 +2023,8 @@ canoe:
can opener: can opener:
label: kitchen label: kitchen
categories:
- cooking
car mirror: car mirror:
label: car label: car
@ -2219,10 +2141,9 @@ crash helmet:
- construction side - construction side
crock pot: crock pot:
label: cooking
categories: categories:
- kitchen - kitchen
- pot
- cooking
dam: dam:
categories: categories:
@ -2278,11 +2199,7 @@ dome:
- building - building
drilling platform: drilling platform:
label: industrial label: building
categories:
- building
- water
- sea
drum: drum:
see: instrument see: instrument
@ -2306,7 +2223,7 @@ electric locomotive:
- vehicle - vehicle
entertainment center: entertainment center:
label: television label: screen
espresso maker: espresso maker:
categories: categories:
@ -2445,7 +2362,7 @@ hatchet:
- tool - tool
home theater: home theater:
label: television label: screen
honeycomb: honeycomb:
priority: -1 priority: -1
@ -2596,7 +2513,6 @@ monitor:
label: screen label: screen
categories: categories:
- display - display
- monitor
- computer - computer
mosque: mosque:
@ -2615,10 +2531,9 @@ mountain bike:
- sports - sports
mountain tent: mountain tent:
label: tent label: camping
categories: categories:
- camping - outdoor
- travel
moving van: moving van:
label: van label: van
@ -2702,11 +2617,10 @@ car:
- vehicle - vehicle
racer: racer:
label: race car label: vehicle
threshold: 0.2 threshold: 0.2
categories: categories:
- car - car
- vehicle
- street - street
passenger car: passenger car:
@ -2735,8 +2649,6 @@ photocopier:
picket fence: picket fence:
label: outdoor label: outdoor
priority: -1 priority: -1
categories:
- fence
pickup: pickup:
categories: categories:
@ -2862,9 +2774,10 @@ rocking chair:
- furniture - furniture
rotisserie: rotisserie:
threshold: 0.5
categories: categories:
- kitchen
- cooking - cooking
- restaurant
rubber eraser: rubber eraser:
categories: categories:
@ -2876,9 +2789,7 @@ running shoe:
saltshaker: saltshaker:
categories: categories:
- kitchen
- cooking - cooking
- food
sandal: sandal:
categories: categories:
@ -2925,11 +2836,12 @@ ski:
- winter - winter
- snow - snow
- sports - sports
- outdoor
sleeping bag: sleeping bag:
categories: categories:
- travel
- camping - camping
- outdoor
sliding door: sliding door:
label: door label: door
@ -2969,7 +2881,6 @@ space heater:
spatula: spatula:
categories: categories:
- kitchen - kitchen
- cooking
speedboat: speedboat:
categories: categories:
@ -3001,12 +2912,10 @@ steel drum:
stove: stove:
categories: categories:
- kitchen - kitchen
- cooking
strainer: strainer:
categories: categories:
- kitchen - kitchen
- cooking
streetcar: streetcar:
categories: categories:
@ -3054,7 +2963,6 @@ theater curtain:
toaster: toaster:
categories: categories:
- kitchen - kitchen
- cooking
toilet seat: toilet seat:
label: toilet label: toilet
@ -3113,7 +3021,6 @@ violin:
waffle iron: waffle iron:
categories: categories:
- kitchen - kitchen
- cooking
wall clock: wall clock:
label: clock label: clock
@ -3148,18 +3055,14 @@ wine bottle:
wok: wok:
categories: categories:
- kitchen - kitchen
- cooking
wooden spoon: wooden spoon:
categories: categories:
- kitchen - kitchen
- cooking
worm fence: worm fence:
label: outdoor label: outdoor
priority: -1 priority: -1
categories:
- fence
wreck: wreck:
see: ship see: ship
@ -3173,7 +3076,9 @@ yawl:
- vehicle - vehicle
yurt: yurt:
label: tent label: camping
categories:
- outdoor
comic book: comic book:
label: colorful label: colorful
@ -3459,9 +3364,7 @@ stinkhorn:
- mushroom - mushroom
earthstar: earthstar:
categories: label: nature
- fungus
- mushroom
hen-of-the-woods: hen-of-the-woods:
categories: categories:
@ -3537,14 +3440,19 @@ spider web:
priority: -2 priority: -2
wool: wool:
label: fur
threshold: 0.5 threshold: 0.5
priority: -1 priority: -1
categories:
- animal
ear: ear:
priority: -1 priority: -1
sunglasses: sunglasses:
label: sunny day
priority: 2 priority: 2
threshold: 0.2
sunglass: sunglass:
see: sunglasses see: sunglasses
@ -3554,10 +3462,9 @@ packet:
priority: -1 priority: -1
swing: swing:
label: cosy label: moment
categories: categories:
- outdoor - outdoor
- furniture
web site: web site:
label: info label: info
@ -3594,9 +3501,9 @@ crutch:
threshold: 0.3 threshold: 0.3
mousetrap: mousetrap:
label: object label: unknown
priority: -1 priority: -1
threshold: 0.3 threshold: 0.5
band aid: band aid:
label: portrait label: portrait
@ -3653,7 +3560,7 @@ patio:
label: building label: building
scoreboard: scoreboard:
label: urban scenery label: scenery
racket: racket:
label: outdoor label: outdoor
@ -3707,6 +3614,8 @@ volcano:
radio telescope: radio telescope:
threshold: 0.5 threshold: 0.5
categories:
- science
thimble: thimble:
priority: -1 priority: -1
@ -3716,3 +3625,24 @@ slot:
carousel: carousel:
label: theme park label: theme park
categories:
- entertainment
groom:
label: wedding
categories:
- event
maypole:
label: festival
categories:
- event
puck:
label: sports
threshold: 0.5
priority: -1
mosquito net:
label: outdoor
priority: -1

View file

@ -41,7 +41,7 @@ services:
CI_JOB_ID: CI_JOB_ID:
photoprism-db: photoprism-db:
image: mariadb:10.4.8 image: mariadb:10.4.11
command: mysqld --port=4001 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=1024 command: mysqld --port=4001 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=1024
expose: expose:
- "4001" - "4001"

View file

@ -37,7 +37,7 @@ services:
TF_CPP_MIN_LOG_LEVEL: 0 TF_CPP_MIN_LOG_LEVEL: 0
photoprism-db: photoprism-db:
image: mariadb:10.4.8 image: mariadb:10.4.11
command: mysqld --port=4001 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=1024 command: mysqld --port=4001 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=1024
expose: expose:
- "4001" - "4001"

View file

@ -47,7 +47,9 @@ func NewCamera(modelName string, makeName string) *Camera {
} }
func (m *Camera) FirstOrCreate(db *gorm.DB) *Camera { func (m *Camera) FirstOrCreate(db *gorm.DB) *Camera {
db.FirstOrCreate(m, "camera_model = ? AND camera_make = ?", m.CameraModel, m.CameraMake) if err := db.FirstOrCreate(m, "camera_model = ? AND camera_make = ?", m.CameraModel, m.CameraMake).Error; err != nil {
log.Errorf("camera: %s", err)
}
return m return m
} }

View file

@ -44,7 +44,9 @@ func NewCountry(countryCode string, countryName string) *Country {
} }
func (m *Country) FirstOrCreate(db *gorm.DB) *Country { func (m *Country) FirstOrCreate(db *gorm.DB) *Country {
db.FirstOrCreate(m, "id = ?", m.ID) if err := db.FirstOrCreate(m, "id = ?", m.ID).Error; err != nil {
log.Errorf("country: %s", err)
}
return m return m
} }

View file

@ -15,8 +15,8 @@ type Event struct {
EventType string EventType string
EventDescription string `gorm:"type:text;"` EventDescription string `gorm:"type:text;"`
EventNotes string `gorm:"type:text;"` EventNotes string `gorm:"type:text;"`
EventBegin time.Time EventBegin time.Time `gorm:"type:datetime;"`
EventEnd time.Time EventEnd time.Time `gorm:"type:datetime;"`
EventLat float64 EventLat float64
EventLong float64 EventLong float64
EventDist float64 EventDist float64

View file

@ -24,7 +24,9 @@ func NewKeyword(keyword string) *Keyword {
} }
func (m *Keyword) FirstOrCreate(db *gorm.DB) *Keyword { func (m *Keyword) FirstOrCreate(db *gorm.DB) *Keyword {
db.FirstOrCreate(m, "keyword = ?", m.Keyword) if err := db.FirstOrCreate(m, "keyword = ?", m.Keyword).Error; err != nil {
log.Errorf("keyword: %s", err)
}
return m return m
} }

View file

@ -24,6 +24,7 @@ type Label struct {
func (m *Label) BeforeCreate(scope *gorm.Scope) error { func (m *Label) BeforeCreate(scope *gorm.Scope) error {
if err := scope.SetColumn("LabelUUID", util.UUID()); err != nil { if err := scope.SetColumn("LabelUUID", util.UUID()); err != nil {
log.Errorf("label: %s", err)
return err return err
} }
@ -49,7 +50,9 @@ func NewLabel(labelName string, labelPriority int) *Label {
} }
func (m *Label) FirstOrCreate(db *gorm.DB) *Label { func (m *Label) FirstOrCreate(db *gorm.DB) *Label {
db.FirstOrCreate(m, "label_slug = ?", m.LabelSlug) if err := db.FirstOrCreate(m, "label_slug = ?", m.LabelSlug).Error; err != nil {
log.Errorf("label: %s", err)
}
return m return m
} }

View file

@ -38,7 +38,9 @@ func NewLens(modelName string, makeName string) *Lens {
} }
func (m *Lens) FirstOrCreate(db *gorm.DB) *Lens { func (m *Lens) FirstOrCreate(db *gorm.DB) *Lens {
db.FirstOrCreate(m, "lens_model = ? AND lens_make = ?", m.LensModel, m.LensMake) if err := db.FirstOrCreate(m, "lens_model = ? AND lens_make = ?", m.LensModel, m.LensMake).Error; err != nil {
log.Errorf("lens: %s", err)
}
return m return m
} }

View file

@ -43,8 +43,8 @@ type Photo struct {
LocationID uint LocationID uint
LocationChanged bool LocationChanged bool
LocationEstimated bool LocationEstimated bool
TakenAt time.Time `gorm:"index;"` TakenAt time.Time `gorm:"type:datetime;index;"`
TakenAtLocal time.Time TakenAtLocal time.Time `gorm:"type:datetime;"`
TakenAtChanged bool TakenAtChanged bool
TimeZone string TimeZone string
Files []File Files []File

View file

@ -31,7 +31,9 @@ func NewPhotoAlbum(photoUUID, albumUUID string) *PhotoAlbum {
} }
func (m *PhotoAlbum) FirstOrCreate(db *gorm.DB) *PhotoAlbum { func (m *PhotoAlbum) FirstOrCreate(db *gorm.DB) *PhotoAlbum {
db.FirstOrCreate(m, "photo_uuid = ? AND album_uuid = ?", m.PhotoUUID, m.AlbumUUID) if err := db.FirstOrCreate(m, "photo_uuid = ? AND album_uuid = ?", m.PhotoUUID, m.AlbumUUID).Error; err != nil {
log.Errorf("photo album: %s", err)
}
return m return m
} }

View file

@ -21,7 +21,9 @@ func NewPhotoKeyword(photoID, keywordID uint) *PhotoKeyword {
} }
func (m *PhotoKeyword) FirstOrCreate(db *gorm.DB) *PhotoKeyword { func (m *PhotoKeyword) FirstOrCreate(db *gorm.DB) *PhotoKeyword {
db.FirstOrCreate(m, "photo_id = ? AND keyword_id = ?", m.PhotoID, m.KeywordID) if err := db.FirstOrCreate(m, "photo_id = ? AND keyword_id = ?", m.PhotoID, m.KeywordID).Error; err != nil {
log.Errorf("photo keyword: %s", err)
}
return m return m
} }

View file

@ -30,7 +30,9 @@ func NewPhotoLabel(photoId, labelId uint, uncertainty int, source string) *Photo
} }
func (m *PhotoLabel) FirstOrCreate(db *gorm.DB) *PhotoLabel { func (m *PhotoLabel) FirstOrCreate(db *gorm.DB) *PhotoLabel {
db.FirstOrCreate(m, "photo_id = ? AND label_id = ?", m.PhotoID, m.LabelID) if err := db.FirstOrCreate(m, "photo_id = ? AND label_id = ?", m.PhotoID, m.LabelID).Error; err != nil {
log.Errorf("photo label: %s", err)
}
return m return m
} }

View file

@ -18,6 +18,7 @@ const (
indexResultUpdated IndexResult = "updated" indexResultUpdated IndexResult = "updated"
indexResultAdded IndexResult = "added" indexResultAdded IndexResult = "added"
indexResultSkipped IndexResult = "skipped" indexResultSkipped IndexResult = "skipped"
indexResultFailed IndexResult = "failed"
) )
type IndexResult string type IndexResult string
@ -163,7 +164,10 @@ func (i *Indexer) indexMediaFile(m *MediaFile, o IndexerOptions) IndexResult {
i.estimateLocation(&photo) i.estimateLocation(&photo)
} }
i.db.Unscoped().Save(&photo) if err := i.db.Unscoped().Save(&photo).Error; err != nil {
log.Errorf("index: %s", err)
return indexResultFailed
}
} else { } else {
event.Publish("count.photos", event.Data{ event.Publish("count.photos", event.Data{
"count": 1, "count": 1,
@ -171,7 +175,10 @@ func (i *Indexer) indexMediaFile(m *MediaFile, o IndexerOptions) IndexResult {
photo.PhotoFavorite = false photo.PhotoFavorite = false
i.db.Create(&photo) if err := i.db.Create(&photo).Error; err != nil {
log.Errorf("index: %s", err)
return indexResultFailed
}
} }
if len(labels) > 0 { if len(labels) > 0 {
@ -217,13 +224,22 @@ func (i *Indexer) indexMediaFile(m *MediaFile, o IndexerOptions) IndexResult {
if fileQuery.Error == nil { if fileQuery.Error == nil {
file.UpdatedIn = int64(time.Since(start)) file.UpdatedIn = int64(time.Since(start))
i.db.Unscoped().Save(&file)
if err := i.db.Unscoped().Save(&file).Error; err != nil {
log.Errorf("index: %s", err)
return indexResultFailed
}
return indexResultUpdated return indexResultUpdated
} }
file.CreatedIn = int64(time.Since(start)) file.CreatedIn = int64(time.Since(start))
i.db.Create(&file) if err := i.db.Create(&file).Error; err != nil {
log.Errorf("index: %s", err)
return indexResultFailed
}
return indexResultAdded return indexResultAdded
} }
@ -322,7 +338,10 @@ func (i *Indexer) addLabels(photoId uint, labels Labels) {
if lm.LabelPriority != label.Priority { if lm.LabelPriority != label.Priority {
lm.LabelPriority = label.Priority lm.LabelPriority = label.Priority
i.db.Save(&lm)
if err := i.db.Save(&lm).Error; err != nil {
log.Errorf("index: %s", err)
}
} }
plm := entity.NewPhotoLabel(photoId, lm.ID, label.Uncertainty, label.Source).FirstOrCreate(i.db) plm := entity.NewPhotoLabel(photoId, lm.ID, label.Uncertainty, label.Source).FirstOrCreate(i.db)
@ -330,13 +349,17 @@ func (i *Indexer) addLabels(photoId uint, labels Labels) {
// Add categories // Add categories
for _, category := range label.Categories { for _, category := range label.Categories {
sn := entity.NewLabel(category, -3).FirstOrCreate(i.db) sn := entity.NewLabel(category, -3).FirstOrCreate(i.db)
i.db.Model(&lm).Association("LabelCategories").Append(sn) if err := i.db.Model(&lm).Association("LabelCategories").Append(sn).Error; err != nil {
log.Errorf("index: %s", err)
}
} }
if plm.LabelUncertainty > label.Uncertainty { if plm.LabelUncertainty > label.Uncertainty {
plm.LabelUncertainty = label.Uncertainty plm.LabelUncertainty = label.Uncertainty
plm.LabelSource = label.Source plm.LabelSource = label.Source
i.db.Save(&plm) if err := i.db.Save(&plm).Error; err != nil {
log.Errorf("index: %s", err)
}
} }
} }
} }