lib/intranet/pictures/json_db_provider.rb in intranet-pictures-1.0.4 vs lib/intranet/pictures/json_db_provider.rb in intranet-pictures-1.0.5
- old
+ new
@@ -180,17 +180,19 @@
end
def select_groups(type, selector)
return @json.fetch('groups').fetch(type) if selector.empty? # optimization
- groups_id = @json.fetch('pictures').map do |p|
- p.fetch(type) if picture_match?(p, selector)
- end.uniq.compact
+ groups_id = select_pictures_having(type, selector).map { |p| p.fetch(type) }.uniq.compact
@json.fetch('groups').fetch(type).select { |g| groups_id.include?(g.fetch('id')) }
end
def select_pictures(selector)
@json.fetch('pictures').select { |p| picture_match?(p, selector) }
+ end
+
+ def select_pictures_having(group_type, selector)
+ @json.fetch('pictures').select { |p| p.key?(group_type) && picture_match?(p, selector) }
end
end
end
end