ad9167360d
* Import: Implement "add to album" in backend #246 Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Import: Implement "add to album" in frontend #246 Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Add OriginalName to photo search result Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Add json tags to PhotoName and PhotoPath Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Photo: Use EstimateCountry() in UpdateLocation() Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Photo: Set OriginalName earlier while indexing Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Ignore whitespace when stripping sequence from filename #335 Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Fix labels count for SQLite Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Import: Show name of new albums #246 Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Frontend: Add acceptance test files Co-authored-by: Michael Mayer <michael@liquidbytes.net>
46 lines
929 B
Go
46 lines
929 B
Go
package query
|
|
|
|
import (
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
"github.com/photoprism/photoprism/internal/form"
|
|
)
|
|
|
|
// AccountSearch returns a list of accounts.
|
|
func AccountSearch(f form.AccountSearch) (result entity.Accounts, err error) {
|
|
s := Db().Where(&entity.Account{})
|
|
|
|
if f.Share {
|
|
s = s.Where("acc_share = 1")
|
|
}
|
|
|
|
if f.Sync {
|
|
s = s.Where("acc_sync = 1")
|
|
}
|
|
|
|
if f.Status != "" {
|
|
s = s.Where("sync_status = ?", f.Status)
|
|
}
|
|
|
|
s = s.Order("acc_name ASC")
|
|
|
|
if f.Count > 0 && f.Count <= 1000 {
|
|
s = s.Limit(f.Count).Offset(f.Offset)
|
|
} else {
|
|
s = s.Limit(1000).Offset(0)
|
|
}
|
|
|
|
if err := s.Find(&result).Error; err != nil {
|
|
return result, err
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// AccountByID finds an account by primary key.
|
|
func AccountByID(id uint) (result entity.Account, err error) {
|
|
if err := Db().Where("id = ?", id).First(&result).Error; err != nil {
|
|
return result, err
|
|
}
|
|
|
|
return result, nil
|
|
}
|