Skip to content

Commit

Permalink
Amélioration du classement des objets récents (événements, pages, act…
Browse files Browse the repository at this point in the history
…ualités) (#1723)

* Fix osunyorg/bordeauxmontaigne-iut#88

* fix

* order lines

---------

Co-authored-by: Sébastien Gaya <sebastien.gaya@gmail.com>
  • Loading branch information
arnaudlevy and SebouChu committed Mar 25, 2024
1 parent b969e11 commit f6a7ef0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/communication/website/agenda/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class Communication::Website::Agenda::Event < ApplicationRecord
scope :ordered_desc, -> { order(from_day: :desc, from_hour: :desc) }
scope :ordered_asc, -> { order(:from_day, :from_hour) }
scope :ordered, -> { ordered_asc }
scope :latest, -> { order(:updated_at).limit(5) }
scope :published, -> { where(published: true) }
scope :draft, -> { where(published: false) }
scope :latest, -> { published.future_or_current.order(:updated_at).limit(5) }

scope :for_category, -> (category_id) {
joins(:categories)
Expand Down
2 changes: 1 addition & 1 deletion app/models/communication/website/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Communication::Website::Page < ApplicationRecord
validates :title, presence: true
validates :header_cta_label, :header_cta_url, presence: true, if: :header_cta

scope :latest, -> { order(updated_at: :desc).limit(5) }
scope :latest, -> { published.order(updated_at: :desc).limit(5) }
scope :published, -> { where(published: true) }
scope :ordered_by_title, -> { order(:title) }

Expand Down
2 changes: 1 addition & 1 deletion app/models/communication/website/portfolio/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Communication::Website::Portfolio::Project < ApplicationRecord
scope :ordered, -> { order(year: :desc, title: :asc) }
scope :published, -> { where(published: true) }
scope :draft, -> { where(published: false) }
scope :latest, -> { order(updated_at: :desc).limit(5) }
scope :latest, -> { published.order(updated_at: :desc).limit(5) }

def git_path(website)
return unless website.id == communication_website_id && published
Expand Down
2 changes: 1 addition & 1 deletion app/models/communication/website/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Communication::Website::Post < ApplicationRecord
")
}
scope :ordered, -> { order(pinned: :desc, published_at: :desc, created_at: :desc) }
scope :latest, -> { order(published_at: :desc).limit(5) }
scope :latest, -> { published.order(published_at: :desc).limit(5) }
scope :for_author, -> (author_id) { where(author_id: author_id) }
scope :for_category, -> (category_id) { joins(:categories).where(communication_website_post_categories: { id: category_id }).distinct }
scope :for_pinned, -> (pinned) { where(pinned: pinned == 'true') }
Expand Down

0 comments on commit f6a7ef0

Please sign in to comment.