Get MBID first, if it is not yet available

This commit is contained in:
Deluan
2021-02-08 11:45:08 -05:00
committed by Deluan Quintão
parent 52a407b84b
commit a76a52e99a
+6 -6
View File
@@ -71,9 +71,13 @@ func (e *externalInfo2) UpdateArtistInfo(ctx context.Context, id string, similar
} }
log.Debug(ctx, "ArtistInfo not cached or expired", "updatedAt", artist.ExternalInfoUpdatedAt, "id", id, "name", artist.Name) log.Debug(ctx, "ArtistInfo not cached or expired", "updatedAt", artist.ExternalInfoUpdatedAt, "id", id, "name", artist.Name)
// Get MBID first, if it is not yet available
if artist.MbzArtistID == "" {
e.callGetMBID(ctx, allAgents, artist)
}
// Call all registered agents and collect information // Call all registered agents and collect information
wg := &sync.WaitGroup{} wg := &sync.WaitGroup{}
e.callGetMBID(ctx, allAgents, artist, wg)
e.callGetBiography(ctx, allAgents, artist, wg) e.callGetBiography(ctx, allAgents, artist, wg)
e.callGetURL(ctx, allAgents, artist, wg) e.callGetURL(ctx, allAgents, artist, wg)
e.callGetImage(ctx, allAgents, artist, wg) e.callGetImage(ctx, allAgents, artist, wg)
@@ -125,10 +129,7 @@ func isDone(ctx context.Context) bool {
} }
} }
func (e *externalInfo2) callGetMBID(ctx context.Context, allAgents []agents.Interface, artist *model.Artist, wg *sync.WaitGroup) { func (e *externalInfo2) callGetMBID(ctx context.Context, allAgents []agents.Interface, artist *model.Artist) {
wg.Add(1)
go func() {
defer wg.Done()
start := time.Now() start := time.Now()
for _, a := range allAgents { for _, a := range allAgents {
if isDone(ctx) { if isDone(ctx) {
@@ -145,7 +146,6 @@ func (e *externalInfo2) callGetMBID(ctx context.Context, allAgents []agents.Inte
break break
} }
} }
}()
} }
func (e *externalInfo2) callGetURL(ctx context.Context, allAgents []agents.Interface, artist *model.Artist, wg *sync.WaitGroup) { func (e *externalInfo2) callGetURL(ctx context.Context, allAgents []agents.Interface, artist *model.Artist, wg *sync.WaitGroup) {