feat: add CreatedAt to albums (#159)
This change will make the GetAlbumList views with the "newest" type work as expected.
This commit is contained in:
@@ -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":
|
||||
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"`
|
||||
@@ -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"`
|
||||
|
||||
BIN
server/ctrlsubsonic/testdata/db
vendored
BIN
server/ctrlsubsonic/testdata/db
vendored
Binary file not shown.
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -132,7 +132,7 @@
|
||||
"name": "",
|
||||
"songCount": 9,
|
||||
"duration": 2169,
|
||||
"created": "0001-01-01T00:00:00Z"
|
||||
"created": "2019-05-23T15:12:02.921473302+01:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -132,7 +132,7 @@
|
||||
"name": "",
|
||||
"songCount": 9,
|
||||
"duration": 2169,
|
||||
"created": "0001-01-01T00:00:00Z"
|
||||
"created": "2019-05-23T15:12:02.921473302+01:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -132,7 +132,7 @@
|
||||
"name": "",
|
||||
"songCount": 15,
|
||||
"duration": 3812,
|
||||
"created": "0001-01-01T00:00:00Z"
|
||||
"created": "2019-04-30T16:48:30+01:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -5,19 +5,6 @@
|
||||
"type": "gonic",
|
||||
"albumList": {
|
||||
"album": [
|
||||
{
|
||||
"id": "al-16",
|
||||
"coverArt": "al-16",
|
||||
"artist": "Swell Maps",
|
||||
"title": "(1980) Jane From Occupied Europe",
|
||||
"album": "",
|
||||
"parent": "al-15",
|
||||
"isDir": true,
|
||||
"name": "",
|
||||
"songCount": 16,
|
||||
"duration": 3040,
|
||||
"created": "0001-01-01T00:00:00Z"
|
||||
},
|
||||
{
|
||||
"id": "al-19",
|
||||
"coverArt": "al-19",
|
||||
@@ -29,33 +16,7 @@
|
||||
"name": "",
|
||||
"songCount": 15,
|
||||
"duration": 3812,
|
||||
"created": "0001-01-01T00:00:00Z"
|
||||
},
|
||||
{
|
||||
"id": "al-17",
|
||||
"coverArt": "al-17",
|
||||
"artist": "Swell Maps",
|
||||
"title": "(1979) A Trip to Marineville",
|
||||
"album": "",
|
||||
"parent": "al-15",
|
||||
"isDir": true,
|
||||
"name": "",
|
||||
"songCount": 18,
|
||||
"duration": 3266,
|
||||
"created": "0001-01-01T00:00:00Z"
|
||||
},
|
||||
{
|
||||
"id": "al-3",
|
||||
"coverArt": "al-3",
|
||||
"artist": "Jah Wobble, The Edge, Holger Czukay",
|
||||
"title": "(1983) Snake Charmer",
|
||||
"album": "",
|
||||
"parent": "al-2",
|
||||
"isDir": true,
|
||||
"name": "",
|
||||
"songCount": 5,
|
||||
"duration": 1871,
|
||||
"created": "0001-01-01T00:00:00Z"
|
||||
"created": "2019-04-30T16:48:30+01:00"
|
||||
},
|
||||
{
|
||||
"id": "al-21",
|
||||
@@ -68,46 +29,20 @@
|
||||
"name": "",
|
||||
"songCount": 15,
|
||||
"duration": 2324,
|
||||
"created": "0001-01-01T00:00:00Z"
|
||||
"created": "2019-06-10T19:26:30.944742894+01:00"
|
||||
},
|
||||
{
|
||||
"id": "al-5",
|
||||
"coverArt": "al-5",
|
||||
"artist": "A Certain Ratio",
|
||||
"title": "(1994) The Graveyard and the Ballroom",
|
||||
"id": "al-17",
|
||||
"coverArt": "al-17",
|
||||
"artist": "Swell Maps",
|
||||
"title": "(1979) A Trip to Marineville",
|
||||
"album": "",
|
||||
"parent": "al-4",
|
||||
"parent": "al-15",
|
||||
"isDir": true,
|
||||
"name": "",
|
||||
"songCount": 14,
|
||||
"duration": 2738,
|
||||
"created": "0001-01-01T00:00:00Z"
|
||||
},
|
||||
{
|
||||
"id": "al-8",
|
||||
"coverArt": "al-8",
|
||||
"artist": "13th Floor Lowervators",
|
||||
"title": "(1967) Easter Nowhere",
|
||||
"album": "",
|
||||
"parent": "al-7",
|
||||
"isDir": true,
|
||||
"name": "",
|
||||
"songCount": 10,
|
||||
"duration": 2609,
|
||||
"created": "0001-01-01T00:00:00Z"
|
||||
},
|
||||
{
|
||||
"id": "al-9",
|
||||
"coverArt": "al-9",
|
||||
"artist": "13th Floor Lowervators",
|
||||
"title": "(1966) The Psychedelic Sounds of the 13th Floor Elevators",
|
||||
"album": "",
|
||||
"parent": "al-7",
|
||||
"isDir": true,
|
||||
"name": "",
|
||||
"songCount": 21,
|
||||
"duration": 4222,
|
||||
"created": "0001-01-01T00:00:00Z"
|
||||
"songCount": 18,
|
||||
"duration": 3266,
|
||||
"created": "2019-04-30T16:48:48+01:00"
|
||||
},
|
||||
{
|
||||
"id": "al-6",
|
||||
@@ -119,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-13",
|
||||
@@ -132,7 +67,72 @@
|
||||
"name": "",
|
||||
"songCount": 9,
|
||||
"duration": 2169,
|
||||
"created": "0001-01-01T00:00:00Z"
|
||||
"created": "2019-05-23T15:12:02.921473302+01:00"
|
||||
},
|
||||
{
|
||||
"id": "al-8",
|
||||
"coverArt": "al-8",
|
||||
"artist": "13th Floor Lowervators",
|
||||
"title": "(1967) Easter Nowhere",
|
||||
"album": "",
|
||||
"parent": "al-7",
|
||||
"isDir": true,
|
||||
"name": "",
|
||||
"songCount": 10,
|
||||
"duration": 2609,
|
||||
"created": "2019-06-13T12:57:28.850090338+01:00"
|
||||
},
|
||||
{
|
||||
"id": "al-9",
|
||||
"coverArt": "al-9",
|
||||
"artist": "13th Floor Lowervators",
|
||||
"title": "(1966) The Psychedelic Sounds of the 13th Floor Elevators",
|
||||
"album": "",
|
||||
"parent": "al-7",
|
||||
"isDir": true,
|
||||
"name": "",
|
||||
"songCount": 21,
|
||||
"duration": 4222,
|
||||
"created": "2019-06-13T12:57:24.306717554+01:00"
|
||||
},
|
||||
{
|
||||
"id": "al-5",
|
||||
"coverArt": "al-5",
|
||||
"artist": "A Certain Ratio",
|
||||
"title": "(1994) The Graveyard and the Ballroom",
|
||||
"album": "",
|
||||
"parent": "al-4",
|
||||
"isDir": true,
|
||||
"name": "",
|
||||
"songCount": 14,
|
||||
"duration": 2738,
|
||||
"created": "2019-06-05T17:46:37.675917974+01:00"
|
||||
},
|
||||
{
|
||||
"id": "al-16",
|
||||
"coverArt": "al-16",
|
||||
"artist": "Swell Maps",
|
||||
"title": "(1980) Jane From Occupied Europe",
|
||||
"album": "",
|
||||
"parent": "al-15",
|
||||
"isDir": true,
|
||||
"name": "",
|
||||
"songCount": 16,
|
||||
"duration": 3040,
|
||||
"created": "2019-04-30T16:48:48+01:00"
|
||||
},
|
||||
{
|
||||
"id": "al-3",
|
||||
"coverArt": "al-3",
|
||||
"artist": "Jah Wobble, The Edge, Holger Czukay",
|
||||
"title": "(1983) Snake Charmer",
|
||||
"album": "",
|
||||
"parent": "al-2",
|
||||
"isDir": true,
|
||||
"name": "",
|
||||
"songCount": 5,
|
||||
"duration": 1871,
|
||||
"created": "2019-05-16T22:10:52+01:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -18,6 +18,19 @@
|
||||
"created": "2019-04-30T16:48:48+01:00",
|
||||
"year": 1979
|
||||
},
|
||||
{
|
||||
"id": "al-9",
|
||||
"coverArt": "al-9",
|
||||
"artistId": "ar-3",
|
||||
"artist": "13th Floor Elevators",
|
||||
"title": "",
|
||||
"album": "",
|
||||
"name": "The Psychedelic Sounds of the 13th Floor Elevators",
|
||||
"songCount": 21,
|
||||
"duration": 4222,
|
||||
"created": "2019-06-13T12:57:24.306717554+01:00",
|
||||
"year": 1966
|
||||
},
|
||||
{
|
||||
"id": "al-16",
|
||||
"coverArt": "al-16",
|
||||
@@ -31,32 +44,6 @@
|
||||
"created": "2019-04-30T16:48:48+01:00",
|
||||
"year": 1980
|
||||
},
|
||||
{
|
||||
"id": "al-21",
|
||||
"coverArt": "al-21",
|
||||
"artistId": "ar-7",
|
||||
"artist": "Captain Beefheart & His Magic Band",
|
||||
"title": "",
|
||||
"album": "",
|
||||
"name": "Lick My Decals Off, Baby",
|
||||
"songCount": 15,
|
||||
"duration": 2324,
|
||||
"created": "2019-06-10T19:26:30.944742894+01:00",
|
||||
"year": 1970
|
||||
},
|
||||
{
|
||||
"id": "al-8",
|
||||
"coverArt": "al-8",
|
||||
"artistId": "ar-3",
|
||||
"artist": "13th Floor Elevators",
|
||||
"title": "",
|
||||
"album": "",
|
||||
"name": "Easter Everywhere",
|
||||
"songCount": 10,
|
||||
"duration": 2609,
|
||||
"created": "2019-06-13T12:57:28.850090338+01:00",
|
||||
"year": 1967
|
||||
},
|
||||
{
|
||||
"id": "al-19",
|
||||
"coverArt": "al-19",
|
||||
@@ -83,30 +70,43 @@
|
||||
"year": 1981
|
||||
},
|
||||
{
|
||||
"id": "al-9",
|
||||
"coverArt": "al-9",
|
||||
"id": "al-8",
|
||||
"coverArt": "al-8",
|
||||
"artistId": "ar-3",
|
||||
"artist": "13th Floor Elevators",
|
||||
"title": "",
|
||||
"album": "",
|
||||
"name": "The Psychedelic Sounds of the 13th Floor Elevators",
|
||||
"songCount": 21,
|
||||
"duration": 4222,
|
||||
"created": "2019-06-13T12:57:24.306717554+01:00",
|
||||
"year": 1966
|
||||
"name": "Easter Everywhere",
|
||||
"songCount": 10,
|
||||
"duration": 2609,
|
||||
"created": "2019-06-13T12:57:28.850090338+01:00",
|
||||
"year": 1967
|
||||
},
|
||||
{
|
||||
"id": "al-13",
|
||||
"coverArt": "al-13",
|
||||
"artistId": "ar-4",
|
||||
"artist": "Anikas",
|
||||
"id": "al-21",
|
||||
"coverArt": "al-21",
|
||||
"artistId": "ar-7",
|
||||
"artist": "Captain Beefheart & His Magic Band",
|
||||
"title": "",
|
||||
"album": "",
|
||||
"name": "Anika",
|
||||
"songCount": 9,
|
||||
"duration": 2169,
|
||||
"created": "2019-05-23T15:12:02.921473302+01:00",
|
||||
"year": 2010
|
||||
"name": "Lick My Decals Off, Baby",
|
||||
"songCount": 15,
|
||||
"duration": 2324,
|
||||
"created": "2019-06-10T19:26:30.944742894+01:00",
|
||||
"year": 1970
|
||||
},
|
||||
{
|
||||
"id": "al-5",
|
||||
"coverArt": "al-5",
|
||||
"artistId": "ar-2",
|
||||
"artist": "A Certain Ratio",
|
||||
"title": "",
|
||||
"album": "",
|
||||
"name": "The Graveyard and the Ballroom",
|
||||
"songCount": 14,
|
||||
"duration": 2738,
|
||||
"created": "2019-06-05T17:46:37.675917974+01:00",
|
||||
"year": 1994
|
||||
},
|
||||
{
|
||||
"id": "al-3",
|
||||
@@ -122,17 +122,17 @@
|
||||
"year": 1983
|
||||
},
|
||||
{
|
||||
"id": "al-5",
|
||||
"coverArt": "al-5",
|
||||
"artistId": "ar-2",
|
||||
"artist": "A Certain Ratio",
|
||||
"id": "al-13",
|
||||
"coverArt": "al-13",
|
||||
"artistId": "ar-4",
|
||||
"artist": "Anikas",
|
||||
"title": "",
|
||||
"album": "",
|
||||
"name": "The Graveyard and the Ballroom",
|
||||
"songCount": 14,
|
||||
"duration": 2738,
|
||||
"created": "2019-06-05T17:46:37.675917974+01:00",
|
||||
"year": 1994
|
||||
"name": "Anika",
|
||||
"songCount": 9,
|
||||
"duration": 2169,
|
||||
"created": "2019-05-23T15:12:02.921473302+01:00",
|
||||
"year": 2010
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
{
|
||||
"id": "al-3",
|
||||
"coverArt": "al-3",
|
||||
"created": "2019-07-08T21:49:40.995905275+01:00",
|
||||
"created": "2019-05-16T22:10:52+01:00",
|
||||
"isDir": true,
|
||||
"isVideo": false,
|
||||
"parent": "al-2",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
{
|
||||
"id": "al-9",
|
||||
"coverArt": "al-9",
|
||||
"created": "2019-07-08T21:49:41.246041678+01:00",
|
||||
"created": "2019-06-13T12:57:24.306717554+01:00",
|
||||
"isDir": true,
|
||||
"isVideo": false,
|
||||
"parent": "al-7",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
{
|
||||
"id": "al-13",
|
||||
"coverArt": "al-13",
|
||||
"created": "2019-07-08T21:49:41.334460116+01:00",
|
||||
"created": "2019-05-23T15:12:02.921473302+01:00",
|
||||
"isDir": true,
|
||||
"isVideo": false,
|
||||
"parent": "al-12",
|
||||
|
||||
@@ -82,6 +82,7 @@ func New(path string) (*DB, error) {
|
||||
migratePodcast(),
|
||||
migrateBookmarks(),
|
||||
migratePodcastAutoDownload(),
|
||||
migrateAlbumCreatedAt(),
|
||||
))
|
||||
if err = migr.Migrate(); err != nil {
|
||||
return nil, fmt.Errorf("migrating to latest version: %w", err)
|
||||
|
||||
@@ -262,3 +262,24 @@ func migratePodcastAutoDownload() gormigrate.Migration {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func migrateAlbumCreatedAt() gormigrate.Migration {
|
||||
return gormigrate.Migration{
|
||||
ID: "202110041330",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
step := tx.AutoMigrate(
|
||||
Album{},
|
||||
)
|
||||
if err := step.Error; err != nil {
|
||||
return fmt.Errorf("step auto migrate: %w", err)
|
||||
}
|
||||
step = tx.Exec(`
|
||||
UPDATE albums SET created_at=modified_at;
|
||||
`)
|
||||
if err := step.Error; err != nil {
|
||||
return fmt.Errorf("step migrate album created_at: %w", err)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,6 +179,7 @@ type Play struct {
|
||||
|
||||
type Album struct {
|
||||
ID int `gorm:"primary_key"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
ModifiedAt time.Time
|
||||
LeftPath string `gorm:"unique_index:idx_left_path_right_path"`
|
||||
|
||||
Reference in New Issue
Block a user