9
9
10
10
def update_song_gaps_for_show
11
11
ActiveRecord ::Base . transaction do
12
- show . tracks . each do |track |
12
+ show . tracks . where . not ( set : "S" ) . each do |track |
13
13
track . songs . each do |song |
14
14
song_track = SongsTrack . find_by ( track_id : track . id , song_id : song . id )
15
15
@@ -32,13 +32,17 @@ def update_song_gaps_for_show
32
32
def find_previous_performance ( song , track )
33
33
previous_tracks = Track . joins ( :show , :songs )
34
34
. where ( songs : { id : song . id } )
35
+ . where ( "tracks.set <> ?" , "S" )
35
36
. where ( "shows.date < ?" , track . show . date )
36
37
. order ( "shows.date DESC, tracks.position DESC" )
37
38
38
- previous_tracks_within_show = track . show . tracks . joins ( :songs )
39
- . where ( songs : { id : song . id } )
40
- . where ( "tracks.position < ?" , track . position )
41
- . order ( "tracks.position DESC" )
39
+ previous_tracks_within_show = track . show
40
+ . tracks
41
+ . joins ( :songs )
42
+ . where ( songs : { id : song . id } )
43
+ . where ( "tracks.set <> ?" , "S" )
44
+ . where ( "tracks.position < ?" , track . position )
45
+ . order ( "tracks.position DESC" )
42
46
43
47
return previous_tracks_within_show . first if previous_tracks_within_show . exists?
44
48
@@ -48,13 +52,17 @@ def find_previous_performance(song, track)
48
52
def find_next_performance ( song , track )
49
53
next_tracks = Track . joins ( :show , :songs )
50
54
. where ( songs : { id : song . id } )
55
+ . where ( "tracks.set <> ?" , "S" )
51
56
. where ( "shows.date > ?" , track . show . date )
52
57
. order ( "shows.date ASC, tracks.position ASC" )
53
58
54
- next_tracks_within_show = track . show . tracks . joins ( :songs )
55
- . where ( songs : { id : song . id } )
56
- . where ( "tracks.position > ?" , track . position )
57
- . order ( "tracks.position ASC" )
59
+ next_tracks_within_show = track . show
60
+ . tracks
61
+ . joins ( :songs )
62
+ . where ( songs : { id : song . id } )
63
+ . where ( "tracks.set <> ?" , "S" )
64
+ . where ( "tracks.position > ?" , track . position )
65
+ . order ( "tracks.position ASC" )
58
66
59
67
return next_tracks_within_show . first if next_tracks_within_show . exists?
60
68
0 commit comments