2020-04-04 17:19:34 +02:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
|
|
)
|
|
|
|
|
2020-04-07 12:51:01 +02:00
|
|
|
// FileSyncs returns a list of FileSync entities for a given account and status.
|
2020-05-08 15:41:01 +02:00
|
|
|
func FileSyncs(accountId uint, status string, limit int) (result []entity.FileSync, err error) {
|
|
|
|
s := Db().Where(&entity.FileSync{})
|
2020-04-04 17:19:34 +02:00
|
|
|
|
|
|
|
if accountId > 0 {
|
|
|
|
s = s.Where("account_id = ?", accountId)
|
|
|
|
}
|
|
|
|
|
|
|
|
if status != "" {
|
|
|
|
s = s.Where("status = ?", status)
|
|
|
|
}
|
|
|
|
|
2020-04-06 22:09:45 +02:00
|
|
|
s = s.Order("remote_name ASC")
|
2020-04-06 22:27:05 +02:00
|
|
|
|
|
|
|
if limit > 0 {
|
|
|
|
s = s.Limit(limit).Offset(0)
|
|
|
|
}
|
2020-04-04 17:19:34 +02:00
|
|
|
|
|
|
|
s = s.Preload("File")
|
|
|
|
|
|
|
|
if err := s.Find(&result).Error; err != nil {
|
|
|
|
return result, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
}
|