2020-04-07 12:51:01 +02:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
|
|
"github.com/photoprism/photoprism/pkg/fs"
|
|
|
|
)
|
|
|
|
|
|
|
|
// AccountUploads a list of files for uploading to a remote account.
|
2020-06-01 09:45:24 +02:00
|
|
|
func AccountUploads(a entity.Account, limit int) (results entity.Files, err error) {
|
2020-05-08 15:41:01 +02:00
|
|
|
s := Db().Where("files.file_missing = 0").
|
2020-04-07 22:03:31 +02:00
|
|
|
Where("files.id NOT IN (SELECT file_id FROM files_sync WHERE file_id > 0 AND account_id = ?)", a.ID)
|
2020-04-07 12:51:01 +02:00
|
|
|
|
|
|
|
if !a.SyncRaw {
|
2022-04-15 09:42:07 +02:00
|
|
|
s = s.Where("files.file_type <> ? OR files.file_type IS NULL", fs.RawImage)
|
2020-04-07 12:51:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
s = s.Order("files.file_name ASC")
|
|
|
|
|
|
|
|
if limit > 0 {
|
|
|
|
s = s.Limit(limit).Offset(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
if result := s.Find(&results); result.Error != nil {
|
|
|
|
return results, result.Error
|
|
|
|
}
|
|
|
|
|
|
|
|
return results, nil
|
|
|
|
}
|