Remove unnecessary repositories methods
This commit is contained in:
@@ -116,15 +116,6 @@ func (r *albumRepository) Put(m *model.Album) error {
|
||||
return r.updateGenres(m.ID, r.tableName, genres)
|
||||
}
|
||||
|
||||
func (r *albumRepository) FindByArtist(artistId string) (model.Albums, error) {
|
||||
options := model.QueryOptions{
|
||||
Sort: "max_year",
|
||||
Filters: Eq{"album_artist_id": artistId},
|
||||
}
|
||||
|
||||
return r.GetAll(options)
|
||||
}
|
||||
|
||||
func (r *albumRepository) GetAll(options ...model.QueryOptions) (model.Albums, error) {
|
||||
sq := r.selectAlbum(options...).
|
||||
LeftJoin("album_genres ag on album.id = ag.album_id").
|
||||
@@ -139,15 +130,6 @@ func (r *albumRepository) GetAll(options ...model.QueryOptions) (model.Albums, e
|
||||
return res, err
|
||||
}
|
||||
|
||||
// TODO Keep order when paginating
|
||||
func (r *albumRepository) GetRandom(options ...model.QueryOptions) (model.Albums, error) {
|
||||
if len(options) == 0 {
|
||||
options = []model.QueryOptions{{}}
|
||||
}
|
||||
options[0].Sort = "random()"
|
||||
return r.GetAll(options...)
|
||||
}
|
||||
|
||||
// Return a map of mediafiles that have embedded covers for the given album ids
|
||||
func (r *albumRepository) getEmbeddedCovers(ids []string) (map[string]model.MediaFile, error) {
|
||||
var mfs model.MediaFiles
|
||||
|
||||
@@ -62,15 +62,6 @@ var _ = Describe("AlbumRepository", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Describe("FindByArtist", func() {
|
||||
It("returns all records from a given ArtistID", func() {
|
||||
Expect(repo.FindByArtist("3")).To(Equal(model.Albums{
|
||||
albumSgtPeppers,
|
||||
albumAbbeyRoad,
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("getMinYear", func() {
|
||||
It("returns 0 when there's no valid year", func() {
|
||||
Expect(getMinYear("a b c")).To(Equal(0))
|
||||
|
||||
@@ -90,14 +90,6 @@ func (r *mediaFileRepository) GetAll(options ...model.QueryOptions) (model.Media
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (r *mediaFileRepository) FindByAlbum(albumId string) (model.MediaFiles, error) {
|
||||
options := model.QueryOptions{
|
||||
Filters: Eq{"album_id": albumId},
|
||||
Sort: "album",
|
||||
}
|
||||
return r.GetAll(options)
|
||||
}
|
||||
|
||||
func (r *mediaFileRepository) FindByPath(path string) (*model.MediaFile, error) {
|
||||
sel := r.selectMediaFile().Where(Eq{"path": path})
|
||||
var res model.MediaFiles
|
||||
@@ -161,15 +153,6 @@ func (r *mediaFileRepository) deleteNotInPath(basePath string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO Keep order when paginating
|
||||
func (r *mediaFileRepository) GetRandom(options ...model.QueryOptions) (model.MediaFiles, error) {
|
||||
if len(options) == 0 {
|
||||
options = []model.QueryOptions{{}}
|
||||
}
|
||||
options[0].Sort = "random()"
|
||||
return r.GetAll(options...)
|
||||
}
|
||||
|
||||
func (r *mediaFileRepository) Delete(id string) error {
|
||||
return r.delete(Eq{"id": id})
|
||||
}
|
||||
|
||||
@@ -41,17 +41,6 @@ var _ = Describe("MediaRepository", func() {
|
||||
Expect(mr.Exists("666")).To(BeFalse())
|
||||
})
|
||||
|
||||
It("find mediafiles by album", func() {
|
||||
Expect(mr.FindByAlbum("103")).To(Equal(model.MediaFiles{
|
||||
songAntenna,
|
||||
songRadioactivity,
|
||||
}))
|
||||
})
|
||||
|
||||
It("returns empty array when no tracks are found", func() {
|
||||
Expect(mr.FindByAlbum("67")).To(Equal(model.MediaFiles{}))
|
||||
})
|
||||
|
||||
It("finds tracks by path when using wildcards chars", func() {
|
||||
Expect(mr.Put(&model.MediaFile{ID: "7001", Path: P("/Find:By'Path/_/123.mp3")})).To(BeNil())
|
||||
Expect(mr.Put(&model.MediaFile{ID: "7002", Path: P("/Find:By'Path/1/123.mp3")})).To(BeNil())
|
||||
|
||||
Reference in New Issue
Block a user