diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-31 18:55:35 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-31 18:55:35 +0200 |
| commit | 683526b38442a9873d83a542b5cba1d15efc14d5 (patch) | |
| tree | 5cdf7d762d829d328e3c6437318d20af72bc65bf /app/models | |
| parent | 464af1625349d557f688da9f845471ef8b80a5f9 (diff) | |
Bind aggregates over scoped tags to their subtree
CccConventions::TAG_SCOPES maps "update" and "pressemitteilung" to /updates
and "disclosure" to /disclosure. Page.aggregate applies the mapping, so an
aggregate over one of those tags is bounded by its subtree regardless of what
the shortcode says. Tags stay unrestricted; positions are publish-gated.
Both RSS actions call Page.aggregate rather than repeating its tag join.
Empty feeds no longer crash: Atom falls back to the current time for the
required <updated>, and the optional dc:date is omitted.
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/page.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/page.rb b/app/models/page.rb index cf003f74..a66527da 100644 --- a/app/models/page.rb +++ b/app/models/page.rb | |||
| @@ -61,7 +61,7 @@ class Page < ApplicationRecord | |||
| 61 | unless options[:tags].blank? | 61 | unless options[:tags].blank? |
| 62 | tag_names = options[:tags].gsub(/\s/, ",").split(",").map(&:strip).map(&:downcase).uniq.reject(&:blank?) | 62 | tag_names = options[:tags].gsub(/\s/, ",").split(",").map(&:strip).map(&:downcase).uniq.reject(&:blank?) |
| 63 | 63 | ||
| 64 | unless tag_names.empty? | 64 | unless tag_names.empty? |
| 65 | scope = scope | 65 | scope = scope |
| 66 | .joins("JOIN taggings ON taggings.taggable_id = pages.id | 66 | .joins("JOIN taggings ON taggings.taggable_id = pages.id |
| 67 | AND taggings.taggable_type = 'Page' | 67 | AND taggings.taggable_type = 'Page' |
| @@ -71,6 +71,11 @@ class Page < ApplicationRecord | |||
| 71 | .group("pages.id") | 71 | .group("pages.id") |
| 72 | .having("COUNT(DISTINCT tags.id) = ?", tag_names.length) | 72 | .having("COUNT(DISTINCT tags.id) = ?", tag_names.length) |
| 73 | end | 73 | end |
| 74 | |||
| 75 | CccConventions::TAG_SCOPES.values_at(*tag_names).compact.uniq.each do |root| | ||
| 76 | scope = scope.where("nodes.unique_name = ? OR nodes.unique_name LIKE ?", | ||
| 77 | root, "#{root}/%") | ||
| 78 | end | ||
| 74 | end | 79 | end |
| 75 | 80 | ||
| 76 | if options[:node] && options[:children] == "direct" | 81 | if options[:node] && options[:children] == "direct" |
