From 6ce6b265df2e147ecaa8a8affb147a5482936831 Mon Sep 17 00:00:00 2001 From: rhymes Date: Wed, 19 Jun 2019 15:17:03 +0200 Subject: [PATCH] Fixed a couple of queries (#3233) --- app/controllers/classified_listings_controller.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/classified_listings_controller.rb b/app/controllers/classified_listings_controller.rb index 29e674bfc..d39ceee14 100644 --- a/app/controllers/classified_listings_controller.rb +++ b/app/controllers/classified_listings_controller.rb @@ -83,9 +83,12 @@ class ClassifiedListingsController < ApplicationController end def dashboard - @classified_listings = ClassifiedListing.where(user_id: current_user.id) - @orgs = Organization.where(id: current_user.organization_memberships.where(type_of_user: "admin").map(&:organization_id)) - @org_listings = ClassifiedListing.where(organization_id: current_user.organization_memberships.where(type_of_user: "admin").map(&:organization_id)) + @classified_listings = current_user.classified_listings + organizations_ids = current_user.organization_memberships. + where(type_of_user: "admin"). + pluck(:organization_id) + @orgs = Organization.where(id: organizations_ids) + @org_listings = ClassifiedListing.where(organization_id: organizations_ids) @user_credits = current_user.unspent_credits_count end