From 3e0a8cff4db25e90d4f70c1d31bf156b35352096 Mon Sep 17 00:00:00 2001 From: chiu Date: Sun, 15 Mar 2020 12:54:44 +0800 Subject: [PATCH] fix error --- app/controllers/galleries_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 4712c3d..27c344a 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -80,8 +80,7 @@ class GalleriesController < ApplicationController album_ids = Album.filter_by_widget_categories.filter_by_tags(tags).pluck(:id) params = OrbitHelper.params counts = OrbitHelper.widget_data_count - pipeline = [{'$match' => {album_id:{"$in"=>album_ids}}},{'$sort'=>{'_id'=>-1}},{ '$limit' => counts *5 }] - images = AlbumImage.collection.aggregate(pipeline).sample(counts) + images = AlbumImage.where({album_id:{"$in"=>album_ids}}).desc(:id).limit(counts *5).sample(counts) images = images.collect do |a| alt_text = (a.description.nil? || a.description == "" ? "gallery image" : a.description) {