5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/outro_rails/chords_controller.rb', line 5
def index
@filters = filter_params
chords = Chord.order(:root_pitch_class, :symbol)
if @filters[:root].present?
chords = chords.where(root_name: @filters[:root])
end
if @filters[:quality].present?
chords = chords.where(quality: @filters[:quality])
end
chords =
case @filters[:extension]
when "none" then chords.where(extension: [ nil, "" ])
when nil, "" then chords
else chords.where(extension: @filters[:extension])
end
chords = chords.to_a
if @filters[:alteration].present?
chords.select! do |chord|
value_tokens(chord.alterations).include?(@filters[:alteration])
end
end
if @filters[:added_tone].present?
chords.select! do |chord|
value_tokens(chord.added_tones).include?(@filters[:added_tone])
end
end
@chords_by_root = chords.group_by(&:root_name)
@missing_query = params[:missing]
end
|