diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-08-25 05:07:39 +0200 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2022-08-25 05:07:39 +0200 |
commit | 2d1d4210f9d394ea8e7357df08f8ca2cc925384a (patch) | |
tree | a5c69693d11b59a673b1981ea2d85bbc17991c42 /app/serializers | |
parent | 5a3d09dc8e30198b4d8d921ef0b1ba0a35fe01d9 (diff) | |
parent | 861b35dd54d266bc0a40b3cacb28e5b82ff6faaa (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/rest/filter_result_serializer.rb | 5 | ||||
-rw-r--r-- | app/serializers/rest/filter_serializer.rb | 1 | ||||
-rw-r--r-- | app/serializers/rest/filter_status_serializer.rb | 13 |
3 files changed, 19 insertions, 0 deletions
diff --git a/app/serializers/rest/filter_result_serializer.rb b/app/serializers/rest/filter_result_serializer.rb index 0ef4db79a..54ead2f1f 100644 --- a/app/serializers/rest/filter_result_serializer.rb +++ b/app/serializers/rest/filter_result_serializer.rb @@ -3,4 +3,9 @@ class REST::FilterResultSerializer < ActiveModel::Serializer belongs_to :filter, serializer: REST::FilterSerializer has_many :keyword_matches + has_many :status_matches + + def status_matches + object.status_matches&.map(&:to_s) + end end diff --git a/app/serializers/rest/filter_serializer.rb b/app/serializers/rest/filter_serializer.rb index 98d7edb17..8816dd807 100644 --- a/app/serializers/rest/filter_serializer.rb +++ b/app/serializers/rest/filter_serializer.rb @@ -3,6 +3,7 @@ class REST::FilterSerializer < ActiveModel::Serializer attributes :id, :title, :context, :expires_at, :filter_action has_many :keywords, serializer: REST::FilterKeywordSerializer, if: :rules_requested? + has_many :statuses, serializer: REST::FilterStatusSerializer, if: :rules_requested? def id object.id.to_s diff --git a/app/serializers/rest/filter_status_serializer.rb b/app/serializers/rest/filter_status_serializer.rb new file mode 100644 index 000000000..6bcbaa249 --- /dev/null +++ b/app/serializers/rest/filter_status_serializer.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class REST::FilterStatusSerializer < ActiveModel::Serializer + attributes :id, :status_id + + def id + object.id.to_s + end + + def status_id + object.status_id.to_s + end +end |