Skip to content

Commit

Permalink
search: use only TrackID in Delete API
Browse files Browse the repository at this point in the history
  • Loading branch information
Wessie committed Mar 25, 2024
1 parent 0093087 commit 9381f37
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion radio.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ type SongInfo struct {
type SearchService interface {
Search(ctx context.Context, query string, limit int64, offset int64) (*SearchResult, error)
Update(context.Context, ...Song) error
Delete(context.Context, ...Song) error
Delete(context.Context, ...TrackID) error
}

type SearchResult struct {
Expand Down
15 changes: 15 additions & 0 deletions search/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,18 @@ func (ts trackStorage) DecrementRequestCount(before time.Time) error {
}
return nil
}

func (ts trackStorage) Delete(id radio.TrackID) error {
const op errors.Op = "search/trackStorage.Delete"

err := ts.wrapped.Delete(id)
if err != nil {
return errors.E(op, err)
}

err = ts.search.Delete(ts.ctx, id)
if err != nil {
return errors.E(op, err)
}
return nil
}
2 changes: 1 addition & 1 deletion storage/mariadb/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (ss SearchService) Update(context.Context, ...radio.Song) error {
return nil
}

func (ss SearchService) Delete(context.Context, ...radio.Song) error {
func (ss SearchService) Delete(context.Context, ...radio.TrackID) error {
// noop since we use the active storage as index
return nil
}

0 comments on commit 9381f37

Please sign in to comment.