Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add CreatedAt to albums #159

Merged
merged 1 commit into from Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/ctrlsubsonic/handlers_by_tags.go
Expand Up @@ -132,7 +132,7 @@ func (c *Controller) ServeGetAlbumListTwo(r *http.Request) *spec.Response {
user.ID)
q = q.Order("plays.count DESC")
case "newest":
q = q.Order("modified_at DESC")
q = q.Order("created_at DESC")
case "random":
q = q.Order(gorm.Expr("random()"))
case "recent":
Expand Down
3 changes: 2 additions & 1 deletion server/ctrlsubsonic/spec/construct_by_folder.go
Expand Up @@ -15,6 +15,7 @@ func NewAlbumByFolder(f *db.Album) *Album {
Title: f.RightPath,
TrackCount: f.ChildCount,
Duration: f.Duration,
Created: f.CreatedAt,
}
if f.Cover != "" {
a.CoverID = f.SID()
Expand All @@ -28,7 +29,7 @@ func NewTCAlbumByFolder(f *db.Album) *TrackChild {
IsDir: true,
Title: f.RightPath,
ParentID: f.ParentSID(),
CreatedAt: f.UpdatedAt,
CreatedAt: f.CreatedAt,
}
if f.Cover != "" {
trCh.CoverID = f.SID()
Expand Down
2 changes: 1 addition & 1 deletion server/ctrlsubsonic/spec/construct_by_tags.go
Expand Up @@ -9,7 +9,7 @@ import (

func NewAlbumByTags(a *db.Album, artist *db.Artist) *Album {
ret := &Album{
Created: a.ModifiedAt,
Created: a.CreatedAt,
ID: a.SID(),
Name: a.TagTitle,
Year: a.TagYear,
Expand Down
2 changes: 1 addition & 1 deletion server/ctrlsubsonic/spec/spec.go
Expand Up @@ -94,6 +94,7 @@ type Album struct {
CoverID *specid.ID `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
ArtistID *specid.ID `xml:"artistId,attr,omitempty" json:"artistId,omitempty"`
Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"`
Created time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`
// browsing by folder (eg. getAlbumList)
Title string `xml:"title,attr,omitempty" json:"title"`
Album string `xml:"album,attr,omitempty" json:"album"`
Expand All @@ -103,7 +104,6 @@ type Album struct {
Name string `xml:"name,attr" json:"name"`
TrackCount int `xml:"songCount,attr" json:"songCount"`
Duration int `xml:"duration,attr" json:"duration"`
Created time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`
Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
Tracks []*TrackChild `xml:"song,omitempty" json:"song,omitempty"`
Expand Down
Binary file modified server/ctrlsubsonic/testdata/db
Binary file not shown.
20 changes: 10 additions & 10 deletions server/ctrlsubsonic/testdata/test_get_album_list_alpha_artist
Expand Up @@ -16,7 +16,7 @@
"name": "",
"songCount": 10,
"duration": 2609,
"created": "0001-01-01T00:00:00Z"
"created": "2019-06-13T12:57:28.850090338+01:00"
},
{
"id": "al-9",
Expand All @@ -29,7 +29,7 @@
"name": "",
"songCount": 21,
"duration": 4222,
"created": "0001-01-01T00:00:00Z"
"created": "2019-06-13T12:57:24.306717554+01:00"
},
{
"id": "al-5",
Expand All @@ -42,7 +42,7 @@
"name": "",
"songCount": 14,
"duration": 2738,
"created": "0001-01-01T00:00:00Z"
"created": "2019-06-05T17:46:37.675917974+01:00"
},
{
"id": "al-6",
Expand All @@ -54,7 +54,7 @@
"name": "",
"songCount": 9,
"duration": 2801,
"created": "0001-01-01T00:00:00Z"
"created": "2019-05-23T15:12:02.921473302+01:00"
},
{
"id": "al-21",
Expand All @@ -67,7 +67,7 @@
"name": "",
"songCount": 15,
"duration": 2324,
"created": "0001-01-01T00:00:00Z"
"created": "2019-06-10T19:26:30.944742894+01:00"
},
{
"id": "al-3",
Expand All @@ -80,7 +80,7 @@
"name": "",
"songCount": 5,
"duration": 1871,
"created": "0001-01-01T00:00:00Z"
"created": "2019-05-16T22:10:52+01:00"
},
{
"id": "al-16",
Expand All @@ -93,7 +93,7 @@
"name": "",
"songCount": 16,
"duration": 3040,
"created": "0001-01-01T00:00:00Z"
"created": "2019-04-30T16:48:48+01:00"
},
{
"id": "al-17",
Expand All @@ -106,7 +106,7 @@
"name": "",
"songCount": 18,
"duration": 3266,
"created": "0001-01-01T00:00:00Z"
"created": "2019-04-30T16:48:48+01:00"
},
{
"id": "al-19",
Expand All @@ -119,7 +119,7 @@
"name": "",
"songCount": 15,
"duration": 3812,
"created": "0001-01-01T00:00:00Z"
"created": "2019-04-30T16:48:30+01:00"
},
{
"id": "al-13",
Expand All @@ -132,7 +132,7 @@
"name": "",
"songCount": 9,
"duration": 2169,
"created": "0001-01-01T00:00:00Z"
"created": "2019-05-23T15:12:02.921473302+01:00"
}
]
}
Expand Down
20 changes: 10 additions & 10 deletions server/ctrlsubsonic/testdata/test_get_album_list_alpha_name
Expand Up @@ -16,7 +16,7 @@
"name": "",
"songCount": 21,
"duration": 4222,
"created": "0001-01-01T00:00:00Z"
"created": "2019-06-13T12:57:24.306717554+01:00"
},
{
"id": "al-8",
Expand All @@ -29,7 +29,7 @@
"name": "",
"songCount": 10,
"duration": 2609,
"created": "0001-01-01T00:00:00Z"
"created": "2019-06-13T12:57:28.850090338+01:00"
},
{
"id": "al-19",
Expand All @@ -42,7 +42,7 @@
"name": "",
"songCount": 15,
"duration": 3812,
"created": "0001-01-01T00:00:00Z"
"created": "2019-04-30T16:48:30+01:00"
},
{
"id": "al-21",
Expand All @@ -55,7 +55,7 @@
"name": "",
"songCount": 15,
"duration": 2324,
"created": "0001-01-01T00:00:00Z"
"created": "2019-06-10T19:26:30.944742894+01:00"
},
{
"id": "al-17",
Expand All @@ -68,7 +68,7 @@
"name": "",
"songCount": 18,
"duration": 3266,
"created": "0001-01-01T00:00:00Z"
"created": "2019-04-30T16:48:48+01:00"
},
{
"id": "al-16",
Expand All @@ -81,7 +81,7 @@
"name": "",
"songCount": 16,
"duration": 3040,
"created": "0001-01-01T00:00:00Z"
"created": "2019-04-30T16:48:48+01:00"
},
{
"id": "al-6",
Expand All @@ -93,7 +93,7 @@
"name": "",
"songCount": 9,
"duration": 2801,
"created": "0001-01-01T00:00:00Z"
"created": "2019-05-23T15:12:02.921473302+01:00"
},
{
"id": "al-3",
Expand All @@ -106,7 +106,7 @@
"name": "",
"songCount": 5,
"duration": 1871,
"created": "0001-01-01T00:00:00Z"
"created": "2019-05-16T22:10:52+01:00"
},
{
"id": "al-5",
Expand All @@ -119,7 +119,7 @@
"name": "",
"songCount": 14,
"duration": 2738,
"created": "0001-01-01T00:00:00Z"
"created": "2019-06-05T17:46:37.675917974+01:00"
},
{
"id": "al-13",
Expand All @@ -132,7 +132,7 @@
"name": "",
"songCount": 9,
"duration": 2169,
"created": "0001-01-01T00:00:00Z"
"created": "2019-05-23T15:12:02.921473302+01:00"
}
]
}
Expand Down
20 changes: 10 additions & 10 deletions server/ctrlsubsonic/testdata/test_get_album_list_newest
Expand Up @@ -16,7 +16,7 @@
"name": "",
"songCount": 10,
"duration": 2609,
"created": "0001-01-01T00:00:00Z"
"created": "2019-06-13T12:57:28.850090338+01:00"
},
{
"id": "al-9",
Expand All @@ -29,7 +29,7 @@
"name": "",
"songCount": 21,
"duration": 4222,
"created": "0001-01-01T00:00:00Z"
"created": "2019-06-13T12:57:24.306717554+01:00"
},
{
"id": "al-21",
Expand All @@ -42,7 +42,7 @@
"name": "",
"songCount": 15,
"duration": 2324,
"created": "0001-01-01T00:00:00Z"
"created": "2019-06-10T19:26:30.944742894+01:00"
},
{
"id": "al-5",
Expand All @@ -55,7 +55,7 @@
"name": "",
"songCount": 14,
"duration": 2738,
"created": "0001-01-01T00:00:00Z"
"created": "2019-06-05T17:46:37.675917974+01:00"
},
{
"id": "al-6",
Expand All @@ -67,7 +67,7 @@
"name": "",
"songCount": 9,
"duration": 2801,
"created": "0001-01-01T00:00:00Z"
"created": "2019-05-23T15:12:02.921473302+01:00"
},
{
"id": "al-13",
Expand All @@ -80,7 +80,7 @@
"name": "",
"songCount": 9,
"duration": 2169,
"created": "0001-01-01T00:00:00Z"
"created": "2019-05-23T15:12:02.921473302+01:00"
},
{
"id": "al-3",
Expand All @@ -93,7 +93,7 @@
"name": "",
"songCount": 5,
"duration": 1871,
"created": "0001-01-01T00:00:00Z"
"created": "2019-05-16T22:10:52+01:00"
},
{
"id": "al-16",
Expand All @@ -106,7 +106,7 @@
"name": "",
"songCount": 16,
"duration": 3040,
"created": "0001-01-01T00:00:00Z"
"created": "2019-04-30T16:48:48+01:00"
},
{
"id": "al-17",
Expand All @@ -119,7 +119,7 @@
"name": "",
"songCount": 18,
"duration": 3266,
"created": "0001-01-01T00:00:00Z"
"created": "2019-04-30T16:48:48+01:00"
},
{
"id": "al-19",
Expand All @@ -132,7 +132,7 @@
"name": "",
"songCount": 15,
"duration": 3812,
"created": "0001-01-01T00:00:00Z"
"created": "2019-04-30T16:48:30+01:00"
}
]
}
Expand Down