Replace beego/orm with dbx (#2693)
* Start migration to dbx package * Fix annotations and bookmarks bindings * Fix tests * Fix more tests * Remove remaining references to beego/orm * Add PostScanner/PostMapper interfaces * Fix importing SmartPlaylists * Renaming * More renaming * Fix artist DB mapping * Fix playlist updates * Remove bookmarks at the end of the test * Remove remaining `orm` struct tags * Fix user timestamps DB access * Fix smart playlist evaluated_at DB access * Fix search3
This commit is contained in:
+1
-1
@@ -143,7 +143,7 @@ func createAdminUser(ctx context.Context, ds model.DataStore, username, password
|
||||
Email: "",
|
||||
NewPassword: password,
|
||||
IsAdmin: true,
|
||||
LastLoginAt: now,
|
||||
LastLoginAt: &now,
|
||||
}
|
||||
err := ds.User(ctx).Put(&initialUser)
|
||||
if err != nil {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
"github.com/navidrome/navidrome/consts"
|
||||
@@ -31,9 +32,11 @@ var _ = Describe("Auth", func() {
|
||||
})
|
||||
|
||||
Describe("createAdmin", func() {
|
||||
var createdAt time.Time
|
||||
BeforeEach(func() {
|
||||
req = httptest.NewRequest("POST", "/createAdmin", strings.NewReader(`{"username":"johndoe", "password":"secret"}`))
|
||||
resp = httptest.NewRecorder()
|
||||
createdAt = time.Now()
|
||||
createAdmin(ds)(resp, req)
|
||||
})
|
||||
|
||||
@@ -43,6 +46,7 @@ var _ = Describe("Auth", func() {
|
||||
Expect(err).To(BeNil())
|
||||
Expect(u.Password).ToNot(BeEmpty())
|
||||
Expect(u.IsAdmin).To(BeTrue())
|
||||
Expect(*u.LastLoginAt).To(BeTemporally(">=", createdAt, time.Second))
|
||||
})
|
||||
|
||||
It("returns the expected payload", func() {
|
||||
|
||||
@@ -352,12 +352,12 @@ func (api *Router) buildArtistDirectory(ctx context.Context, artist *model.Artis
|
||||
dir.Name = artist.Name
|
||||
dir.PlayCount = artist.PlayCount
|
||||
if artist.PlayCount > 0 {
|
||||
dir.Played = &artist.PlayDate
|
||||
dir.Played = artist.PlayDate
|
||||
}
|
||||
dir.AlbumCount = int32(artist.AlbumCount)
|
||||
dir.UserRating = int32(artist.Rating)
|
||||
if artist.Starred {
|
||||
dir.Starred = &artist.StarredAt
|
||||
dir.Starred = artist.StarredAt
|
||||
}
|
||||
|
||||
albums, err := api.ds.Album(ctx).GetAllWithoutGenres(filter.AlbumsByArtistID(artist.ID))
|
||||
@@ -390,13 +390,13 @@ func (api *Router) buildAlbumDirectory(ctx context.Context, album *model.Album)
|
||||
dir.Parent = album.AlbumArtistID
|
||||
dir.PlayCount = album.PlayCount
|
||||
if album.PlayCount > 0 {
|
||||
dir.Played = &album.PlayDate
|
||||
dir.Played = album.PlayDate
|
||||
}
|
||||
dir.UserRating = int32(album.Rating)
|
||||
dir.SongCount = int32(album.SongCount)
|
||||
dir.CoverArt = album.CoverArtID().String()
|
||||
if album.Starred {
|
||||
dir.Starred = &album.StarredAt
|
||||
dir.Starred = album.StarredAt
|
||||
}
|
||||
|
||||
mfs, err := api.ds.MediaFile(ctx).GetAll(filter.SongsByAlbum(album.ID))
|
||||
@@ -419,7 +419,7 @@ func (api *Router) buildAlbum(ctx context.Context, album *model.Album, mfs model
|
||||
dir.Duration = int32(album.Duration)
|
||||
dir.PlayCount = album.PlayCount
|
||||
if album.PlayCount > 0 {
|
||||
dir.Played = &album.PlayDate
|
||||
dir.Played = album.PlayDate
|
||||
}
|
||||
dir.Year = int32(album.MaxYear)
|
||||
dir.Genre = album.Genre
|
||||
@@ -429,7 +429,7 @@ func (api *Router) buildAlbum(ctx context.Context, album *model.Album, mfs model
|
||||
dir.Created = &album.CreatedAt
|
||||
}
|
||||
if album.Starred {
|
||||
dir.Starred = &album.StarredAt
|
||||
dir.Starred = album.StarredAt
|
||||
}
|
||||
dir.MusicBrainzId = album.MbzAlbumID
|
||||
dir.IsCompilation = album.Compilation
|
||||
|
||||
@@ -97,7 +97,7 @@ func toArtist(r *http.Request, a model.Artist) responses.Artist {
|
||||
ArtistImageUrl: public.ImageURL(r, a.CoverArtID(), 600),
|
||||
}
|
||||
if a.Starred {
|
||||
artist.Starred = &a.StarredAt
|
||||
artist.Starred = a.StarredAt
|
||||
}
|
||||
return artist
|
||||
}
|
||||
@@ -114,7 +114,7 @@ func toArtistID3(r *http.Request, a model.Artist) responses.ArtistID3 {
|
||||
SortName: a.SortArtistName,
|
||||
}
|
||||
if a.Starred {
|
||||
artist.Starred = &a.StarredAt
|
||||
artist.Starred = a.StarredAt
|
||||
}
|
||||
return artist
|
||||
}
|
||||
@@ -174,10 +174,10 @@ func childFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Child
|
||||
child.Type = "music"
|
||||
child.PlayCount = mf.PlayCount
|
||||
if mf.PlayCount > 0 {
|
||||
child.Played = &mf.PlayDate
|
||||
child.Played = mf.PlayDate
|
||||
}
|
||||
if mf.Starred {
|
||||
child.Starred = &mf.StarredAt
|
||||
child.Starred = mf.StarredAt
|
||||
}
|
||||
child.UserRating = int32(mf.Rating)
|
||||
|
||||
@@ -239,11 +239,11 @@ func childFromAlbum(_ context.Context, al model.Album) responses.Child {
|
||||
child.Duration = int32(al.Duration)
|
||||
child.SongCount = int32(al.SongCount)
|
||||
if al.Starred {
|
||||
child.Starred = &al.StarredAt
|
||||
child.Starred = al.StarredAt
|
||||
}
|
||||
child.PlayCount = al.PlayCount
|
||||
if al.PlayCount > 0 {
|
||||
child.Played = &al.PlayDate
|
||||
child.Played = al.PlayDate
|
||||
}
|
||||
child.UserRating = int32(al.Rating)
|
||||
child.SortName = al.SortAlbumName
|
||||
|
||||
@@ -110,7 +110,7 @@ func (api *Router) Search2(r *http.Request) (*responses.Subsonic, error) {
|
||||
ArtistImageUrl: public.ImageURL(r, artist.CoverArtID(), 600),
|
||||
}
|
||||
if artist.Starred {
|
||||
searchResult2.Artist[i].Starred = &as[i].StarredAt
|
||||
searchResult2.Artist[i].Starred = as[i].StarredAt
|
||||
}
|
||||
}
|
||||
searchResult2.Album = childrenFromAlbums(ctx, als)
|
||||
|
||||
Reference in New Issue
Block a user