Add Stars to the DB, including Artists! Only if DevUseFolderScanner is true
This commit is contained in:
@@ -32,7 +32,7 @@ type mediaFile struct {
|
||||
PlayDate time.Time `orm:"null"`
|
||||
Rating int `orm:"index"`
|
||||
Starred bool `orm:"index"`
|
||||
StarredAt time.Time `orm:"null"`
|
||||
StarredAt time.Time `orm:"index;null"`
|
||||
CreatedAt time.Time `orm:"null"`
|
||||
UpdatedAt time.Time `orm:"null"`
|
||||
}
|
||||
@@ -135,6 +135,29 @@ func (r *mediaFileRepository) GetStarred(options ...model.QueryOptions) (model.M
|
||||
return r.toMediaFiles(starred), nil
|
||||
}
|
||||
|
||||
func (r *mediaFileRepository) SetStar(starred bool, ids ...string) error {
|
||||
if len(ids) == 0 {
|
||||
return model.ErrNotFound
|
||||
}
|
||||
var starredAt time.Time
|
||||
if starred {
|
||||
starredAt = time.Now()
|
||||
}
|
||||
_, err := r.newQuery(Db()).Filter("id__in", ids).Update(orm.Params{
|
||||
"starred": starred,
|
||||
"starred_at": starredAt,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *mediaFileRepository) SetRating(rating int, ids ...string) error {
|
||||
if len(ids) == 0 {
|
||||
return model.ErrNotFound
|
||||
}
|
||||
_, err := r.newQuery(Db()).Filter("id__in", ids).Update(orm.Params{"rating": rating})
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *mediaFileRepository) PurgeInactive(activeList model.MediaFiles) error {
|
||||
return withTx(func(o orm.Ormer) error {
|
||||
_, err := r.purgeInactive(o, activeList, func(item interface{}) string {
|
||||
|
||||
Reference in New Issue
Block a user