mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-31 07:30:32 +00:00
Merge bf7f9942c54f6354bd68bc3ea01f2b2cc2b6436d into ff583970f099df7c2bec649aa6a928756387dc1b
This commit is contained in:
commit
ef1f143080
@ -0,0 +1,7 @@
|
|||||||
|
-- +goose Up
|
||||||
|
-- +goose StatementBegin
|
||||||
|
ALTER TABLE annotation ADD COLUMN rated_at datetime;
|
||||||
|
-- +goose StatementEnd
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
|
||||||
@ -6,6 +6,7 @@ type Annotations struct {
|
|||||||
PlayCount int64 `structs:"play_count" json:"playCount,omitempty"`
|
PlayCount int64 `structs:"play_count" json:"playCount,omitempty"`
|
||||||
PlayDate *time.Time `structs:"play_date" json:"playDate,omitempty" `
|
PlayDate *time.Time `structs:"play_date" json:"playDate,omitempty" `
|
||||||
Rating int `structs:"rating" json:"rating,omitempty" `
|
Rating int `structs:"rating" json:"rating,omitempty" `
|
||||||
|
RatedAt *time.Time `structs:"rated_at" json:"ratedAt,omitempty" `
|
||||||
Starred bool `structs:"starred" json:"starred,omitempty" `
|
Starred bool `structs:"starred" json:"starred,omitempty" `
|
||||||
StarredAt *time.Time `structs:"starred_at" json:"starredAt,omitempty"`
|
StarredAt *time.Time `structs:"starred_at" json:"starredAt,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,6 +44,7 @@ var fieldMap = map[string]*mappedField{
|
|||||||
"loved": {field: "COALESCE(annotation.starred, false)"},
|
"loved": {field: "COALESCE(annotation.starred, false)"},
|
||||||
"dateloved": {field: "annotation.starred_at"},
|
"dateloved": {field: "annotation.starred_at"},
|
||||||
"lastplayed": {field: "annotation.play_date"},
|
"lastplayed": {field: "annotation.play_date"},
|
||||||
|
"daterated": {field: "annotation.rated_at"},
|
||||||
"playcount": {field: "COALESCE(annotation.play_count, 0)"},
|
"playcount": {field: "COALESCE(annotation.play_count, 0)"},
|
||||||
"rating": {field: "COALESCE(annotation.rating, 0)"},
|
"rating": {field: "COALESCE(annotation.rating, 0)"},
|
||||||
"mbz_album_id": {field: "media_file.mbz_album_id"},
|
"mbz_album_id": {field: "media_file.mbz_album_id"},
|
||||||
|
|||||||
@ -388,6 +388,7 @@ func (r *playlistRepository) loadTracks(sel SelectBuilder, id string) (model.Pla
|
|||||||
"coalesce(play_count, 0) as play_count",
|
"coalesce(play_count, 0) as play_count",
|
||||||
"play_date",
|
"play_date",
|
||||||
"coalesce(rating, 0) as rating",
|
"coalesce(rating, 0) as rating",
|
||||||
|
"rated_at",
|
||||||
"f.*",
|
"f.*",
|
||||||
"playlist_tracks.*",
|
"playlist_tracks.*",
|
||||||
"library.path as library_path",
|
"library.path as library_path",
|
||||||
|
|||||||
@ -97,6 +97,7 @@ func (r *playlistTrackRepository) Read(id string) (interface{}, error) {
|
|||||||
"coalesce(rating, 0) as rating",
|
"coalesce(rating, 0) as rating",
|
||||||
"starred_at",
|
"starred_at",
|
||||||
"play_date",
|
"play_date",
|
||||||
|
"rated_at",
|
||||||
"f.*",
|
"f.*",
|
||||||
"playlist_tracks.*",
|
"playlist_tracks.*",
|
||||||
).
|
).
|
||||||
|
|||||||
@ -28,6 +28,7 @@ func (r sqlRepository) withAnnotation(query SelectBuilder, idField string) Selec
|
|||||||
"coalesce(rating, 0) as rating",
|
"coalesce(rating, 0) as rating",
|
||||||
"starred_at",
|
"starred_at",
|
||||||
"play_date",
|
"play_date",
|
||||||
|
"rated_at",
|
||||||
)
|
)
|
||||||
if conf.Server.AlbumPlayCountMode == consts.AlbumPlayCountModeNormalized && r.tableName == "album" {
|
if conf.Server.AlbumPlayCountMode == consts.AlbumPlayCountModeNormalized && r.tableName == "album" {
|
||||||
query = query.Columns(
|
query = query.Columns(
|
||||||
@ -77,7 +78,8 @@ func (r sqlRepository) SetStar(starred bool, ids ...string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r sqlRepository) SetRating(rating int, itemID string) error {
|
func (r sqlRepository) SetRating(rating int, itemID string) error {
|
||||||
return r.annUpsert(map[string]interface{}{"rating": rating}, itemID)
|
ratedAt := time.Now()
|
||||||
|
return r.annUpsert(map[string]interface{}{"rating": rating, "rated_at": ratedAt}, itemID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r sqlRepository) IncPlayCount(itemID string, ts time.Time) error {
|
func (r sqlRepository) IncPlayCount(itemID string, ts time.Time) error {
|
||||||
|
|||||||
@ -46,8 +46,13 @@ export const LoveButton = ({
|
|||||||
<Button
|
<Button
|
||||||
onClick={handleToggleLove}
|
onClick={handleToggleLove}
|
||||||
size={'small'}
|
size={'small'}
|
||||||
disabled={disabled || loading || record?.missing}
|
disabled={disabled || loading || record.missing}
|
||||||
className={classes.love}
|
className={classes.love}
|
||||||
|
title={
|
||||||
|
record.starredAt
|
||||||
|
? new Date(record.starredAt).toLocaleString()
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
{record.starred ? (
|
{record.starred ? (
|
||||||
|
|||||||
@ -45,7 +45,12 @@ export const RatingField = ({
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span onClick={(e) => stopPropagation(e)}>
|
<span
|
||||||
|
onClick={(e) => stopPropagation(e)}
|
||||||
|
title={
|
||||||
|
record.ratedAt ? new Date(record.ratedAt).toLocaleString() : undefined
|
||||||
|
}
|
||||||
|
>
|
||||||
<Rating
|
<Rating
|
||||||
name={record.mediaFileId || record.id}
|
name={record.mediaFileId || record.id}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user