Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amélioration du classement des objets récents (événements, pages, actualités) #1723

Merged
merged 5 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/models/communication/website/agenda/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ 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 :recent, -> { order(:updated_at).limit(5) }
scope :published, -> { where(published: true) }
scope :draft, -> { where(published: false) }

scope :recent, -> { published.future_or_current.limit(5) }
SebouChu marked this conversation as resolved.
Show resolved Hide resolved

scope :for_category, -> (category_id) {
joins(:categories)
.where(
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 :recent, -> { order(updated_at: :desc).limit(5) }
scope :recent, -> { 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/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 :recent, -> { order(published_at: :desc).limit(5) }
scope :recent, -> { 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
Loading