Skip to content

Commit

Permalink
Improve Enclosure API: Restrict related entries count
Browse files Browse the repository at this point in the history
  • Loading branch information
kumabook committed Feb 28, 2018
1 parent 04392f0 commit 42ea358
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/enclosure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Enclosure < ApplicationRecord
include Savable
include Playable

ENTRIES_LIMIT = 100
PARTIAL_ENTRIES_LIMIT = 100

after_create :purge_all
Expand All @@ -16,7 +17,7 @@ class Enclosure < ApplicationRecord
enum provider: [:Raw, :Custom, :YouTube, :SoundCloud, :Spotify, :AppleMusic]

has_many :entry_enclosures, dependent: :destroy
has_many :entries, ->{order("entries.published DESC") }, through: :entry_enclosures
has_many :entries, ->{ order("entries.published DESC").limit(ENTRIES_LIMIT) }, through: :entry_enclosures

has_many :enclosure_issues, dependent: :destroy
has_many :issues , through: :enclosure_issues
Expand Down

0 comments on commit 42ea358

Please sign in to comment.