diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index ec2a85961..209fa8506 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -34,6 +34,9 @@ class PostQueryBuilder when :lte relation.where(["#{field} <= ?", arr[1]]) + + when :in + relation.where(["#{field} in (?)", arr[1]]) when :between relation.where(["#{field} BETWEEN ? AND ?", arr[1], arr[2]]) diff --git a/app/models/pool.rb b/app/models/pool.rb index 584f017f5..eb65548cd 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -114,6 +114,10 @@ class Pool < ActiveRecord::Base name.tr("_", " ") end + def creator_name + User.id_to_name(creator_id) + end + def normalize_post_ids self.post_ids = self.class.normalize_post_ids(post_ids) end @@ -237,4 +241,27 @@ class Pool < ActiveRecord::Base @neighbor_posts = nil clear_post_id_array end + + def to_xml(options = {}, &block) + # to_xml ignores the serializable_hash method + options ||= {} + options[:methods] = [:creator_name] + super(options, &block) + end + + def serializable_hash(options = {}) + return { + "created_at" => created_at, + "creator_id" => creator_id, + "creator_name" => creator_name, + "description" => description, + "id" => id, + "is_active" => is_active?, + "is_deleted" => is_deleted?, + "name" => name, + "post_count" => post_count, + "post_ids" => post_ids, + "updated_at" => updated_at + } + end end diff --git a/app/models/post.rb b/app/models/post.rb index fc2f2afcd..2bf7b319e 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -817,6 +817,7 @@ class Post < ActiveRecord::Base def to_xml(options = {}, &block) # to_xml ignores the serializable_hash method options ||= {} + options[:methods] = [:uploader_name] options[:except] ||= [] options[:except] += hidden_attributes super(options, &block) diff --git a/app/models/tag.rb b/app/models/tag.rb index d5f845d94..374e3d08d 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -199,6 +199,9 @@ class Tag < ActiveRecord::Base when /\A>(.+)/ return [:gt, parse_cast($1, type)] + + when /,/ + return [:in, range.split(/,/)] else return [:eq, parse_cast(range, type)]