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 {
|
2022-10-15 21:54:11 +02:00
|
|
|
s = s.Where("service_id = ?", accountId)
|
2020-04-04 17:19:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|