mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-19 15:23:36 +00:00
feat(repository): apply library filtering in CountAll methods for albums, folders, and media files
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
1 parent
f9fc3cd1c6
commit
e9d6a8eccf
4 files changed
+9
-6
No files matched your search
@@ -184,9 +184,10 @@ func allRolesFilter(_ string, value interface{}) Sqlizer {
|
||||
}
|
||||
|
||||
func (r *albumRepository) CountAll(options ...model.QueryOptions) (int64, error) {
|
||||
sql := r.newSelect()
|
||||
sql = r.withAnnotation(sql, "album.id")
|
||||
return r.count(sql, options...)
|
||||
query := r.newSelect()
|
||||
query = r.withAnnotation(query, "album.id")
|
||||
query = r.applyLibraryFilter(query)
|
||||
return r.count(query, options...)
|
||||
}
|
||||
|
||||
func (r *albumRepository) Exists(id string) (bool, error) {
|
||||
|
||||
@@ -21,7 +21,7 @@ var _ = Describe("ArtistRepository", func() {
|
||||
BeforeEach(func() {
|
||||
DeferCleanup(configtest.SetupConfig())
|
||||
ctx := log.NewContext(context.TODO())
|
||||
ctx = request.WithUser(ctx, model.User{ID: "userid"})
|
||||
ctx = request.WithUser(ctx, adminUser)
|
||||
repo = NewArtistRepository(ctx, GetDBXBuilder())
|
||||
})
|
||||
|
||||
|
||||
@@ -86,8 +86,9 @@ func (r folderRepository) GetAll(opt ...model.QueryOptions) ([]model.Folder, err
|
||||
}
|
||||
|
||||
func (r folderRepository) CountAll(opt ...model.QueryOptions) (int64, error) {
|
||||
sq := r.newSelect(opt...).Columns("count(*)")
|
||||
return r.count(sq)
|
||||
query := r.newSelect(opt...).Columns("count(*)")
|
||||
query = r.applyLibraryFilter(query)
|
||||
return r.count(query)
|
||||
}
|
||||
|
||||
func (r folderRepository) GetLastUpdates(lib model.Library) (map[string]model.FolderUpdateInfo, error) {
|
||||
|
||||
@@ -116,6 +116,7 @@ func mediaFileRecentlyAddedSort() string {
|
||||
func (r *mediaFileRepository) CountAll(options ...model.QueryOptions) (int64, error) {
|
||||
query := r.newSelect()
|
||||
query = r.withAnnotation(query, "media_file.id")
|
||||
query = r.applyLibraryFilter(query)
|
||||
return r.count(query, options...)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user