Skip to content

Commit

Permalink
Remove unnecessary reciter from audio response (#75)
Browse files Browse the repository at this point in the history
The audio structure in the json was repeated per ayah - this is not
necessary (as a matter of fact, it's not needed at all, since the
reciter id is already known before making this call). This saves a
database query and a very small amount of transfer (4k uncompressed,
much less compressed (~100 bytes)).
  • Loading branch information
ahmedre authored and mmahalwy committed Aug 22, 2016
1 parent 6638e3b commit e892043
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/audio/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ def as_json(options = {})
ayah = ayah_key.split(':')[1]


super(only: [:duration, :url, :encrypted_segments], include: :reciter)
super(only: [:duration, :url, :encrypted_segments])
end
end
1 change: 0 additions & 1 deletion app/models/quran/ayah.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def self.as_json_with_resources(ayahs, options = {})
if audio_option = options[:audio]
audio =
Audio::File
.preload(:reciter)
.where(ayah_key: keys, recitation_id: audio_option, is_enabled: true)
.order(:ayah_key)
.group_by(&:ayah_key)
Expand Down

0 comments on commit e892043

Please sign in to comment.