@@ -321,13 +321,13 @@ private async Task<Source> ProcessShow(ImportStats stats, Artist artist, string
321321 var tracks = apiShow . tracks . ToList ( ) ;
322322
323323 taperNotes . AddRange ( apiShow . txts ) ;
324-
324+
325325 foreach ( var track in tracks )
326326 {
327327 var localTrackPosition = track . tags . track . no ;
328328
329329 // we add one to tracksAdded because track positions are not zero-indexed
330- // they start at 1, but tracksAdded is zero indexed
330+ // they start at 1, but tracksAdded is zero indexed
331331 if ( localTrackPosition < tracksAdded + 1 ) localTrackPosition += tracksAdded ;
332332
333333 var st = new SourceTrack
@@ -395,67 +395,68 @@ public async Task<ImportStats> ProcessShows(Artist artist, ArtistUpstreamSource
395395
396396 async Task processDay ( string date , IList < LocalShow > shows )
397397 {
398- using ( var scope = new TransactionScope ( TransactionScopeAsyncFlowOption . Enabled ) )
398+ using var scope = new TransactionScope ( TransactionScopeOption . Required ,
399+ new TransactionOptions ( ) { IsolationLevel = IsolationLevel . RepeatableRead } ,
400+ TransactionScopeAsyncFlowOption . Enabled ) ;
401+
402+ var firstShow = shows . First ( ) ;
403+ var dbSource = existingSources . GetValue ( date ) ;
404+ var venueUpstreamId = $ "{ firstShow . venue } { firstShow . city } , { firstShow . state } ";
405+
406+ if ( dbSource == null )
399407 {
400- var firstShow = shows . First ( ) ;
401- var dbSource = existingSources . GetValue ( date ) ;
402- var venueUpstreamId = $ "{ firstShow . venue } { firstShow . city } , { firstShow . state } ";
408+ dbSource = await ProcessShow ( stats , artist , date , shows , src ,
409+ new Source
410+ {
411+ updated_at = firstShow . updated_at ,
412+ artist_id = artist . id ,
413+ venue_id = existingVenues [ venueUpstreamId ] . id ,
414+ display_date = date ,
415+ upstream_identifier = date ,
416+ is_soundboard = false ,
417+ is_remaster = false ,
418+ description = "" ,
419+ taper_notes = ""
420+ } , ctx ) ;
403421
404- if ( dbSource == null )
405- {
406- dbSource = await ProcessShow ( stats , artist , date , shows , src ,
407- new Source
408- {
409- updated_at = firstShow . updated_at ,
410- artist_id = artist . id ,
411- venue_id = existingVenues [ venueUpstreamId ] . id ,
412- display_date = date ,
413- upstream_identifier = date ,
414- is_soundboard = false ,
415- is_remaster = false ,
416- description = "" ,
417- taper_notes = ""
418- } , ctx ) ;
419-
420- existingSources [ dbSource . upstream_identifier ] = dbSource ;
422+ existingSources [ dbSource . upstream_identifier ] = dbSource ;
421423
422- stats . Created ++ ;
424+ stats . Created ++ ;
423425
424- await linkService . AddLinksForSource ( dbSource ,
425- new [ ]
426+ await linkService . AddLinksForSource ( dbSource ,
427+ new [ ]
428+ {
429+ new Link
426430 {
427- new Link
428- {
429- source_id = dbSource . id ,
430- for_ratings = true ,
431- for_source = false ,
432- for_reviews = true ,
433- upstream_source_id = src . upstream_source_id ,
434- url = "http://phish.net/setlists/?d=" + dbSource . display_date ,
435- label = "View on phish.net"
436- }
437- } ) ;
438- }
439- else if ( firstShow . updated_at > dbSource . updated_at )
440- {
441- dbSource . updated_at = firstShow . updated_at ;
442- dbSource . venue_id = existingVenues [ venueUpstreamId ] . id ;
443- dbSource . display_date = date ;
444- dbSource . upstream_identifier = date ;
445- dbSource . is_soundboard = firstShow . sbd ;
446- dbSource . is_remaster = firstShow . remastered ;
447- dbSource . description = "" ;
448- dbSource . taper_notes = "" ;
449-
450- dbSource = await ProcessShow ( stats , artist , date , shows , src , dbSource , ctx ) ;
431+ source_id = dbSource . id ,
432+ for_ratings = true ,
433+ for_source = false ,
434+ for_reviews = true ,
435+ upstream_source_id = src . upstream_source_id ,
436+ url = "http://phish.net/setlists/?d=" + dbSource . display_date ,
437+ label = "View on phish.net"
438+ }
439+ } ) ;
440+ }
441+ else if ( firstShow . updated_at > dbSource . updated_at )
442+ {
443+ dbSource . updated_at = firstShow . updated_at ;
444+ dbSource . venue_id = existingVenues [ venueUpstreamId ] . id ;
445+ dbSource . display_date = date ;
446+ dbSource . upstream_identifier = date ;
447+ dbSource . is_soundboard = firstShow . sbd ;
448+ dbSource . is_remaster = firstShow . remastered ;
449+ dbSource . description = "" ;
450+ dbSource . taper_notes = "" ;
451451
452- existingSources [ dbSource . upstream_identifier ] = dbSource ;
452+ dbSource = await ProcessShow ( stats , artist , date , shows , src , dbSource , ctx ) ;
453453
454- stats . Updated ++ ;
455- }
454+ existingSources [ dbSource . upstream_identifier ] = dbSource ;
456455
457- scope . Complete ( ) ;
456+ stats . Updated ++ ;
458457 }
458+
459+ scope . Complete ( ) ;
459460 }
460461
461462 return stats ;
0 commit comments