From 9381f378c26ae260b52395f68917a553de28d5a2 Mon Sep 17 00:00:00 2001 From: Wessie Date: Mon, 25 Mar 2024 21:21:26 +0000 Subject: [PATCH] search: use only TrackID in Delete API --- radio.go | 2 +- search/storage.go | 15 +++++++++++++++ storage/mariadb/search.go | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/radio.go b/radio.go index fa33272d..57bcdf9b 100644 --- a/radio.go +++ b/radio.go @@ -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 { diff --git a/search/storage.go b/search/storage.go index 781f06b3..80181871 100644 --- a/search/storage.go +++ b/search/storage.go @@ -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 +} diff --git a/storage/mariadb/search.go b/storage/mariadb/search.go index c231d56d..52fef104 100644 --- a/storage/mariadb/search.go +++ b/storage/mariadb/search.go @@ -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 }