get dashboard loading with use_qualified_names

refs CNVS-21900, CNVS-21901

test plan:
 * in database.yml, set
     use_qualified_names: true
     schema_search_path: pg_catalog
     shard_name: public
   (probably public; adjust as necessary)
 * you should be able to login and view your dashboard without
   any 500 errors

Change-Id: I6f5bc538dcae25a7f57425411648800fbc5bd259
Reviewed-on: https://gerrit.instructure.com/58528
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Cody Cutrer 2015-07-15 13:23:27 -06:00
parent 9e353116ce
commit a56e81bd9e
3 changed files with 7 additions and 5 deletions

View File

@ -646,9 +646,9 @@ class Account < ActiveRecord::Base
chain = Shard.shard_for(starting_account_id).activate do
Account.find_by_sql(<<-SQL)
WITH RECURSIVE t AS (
SELECT * FROM accounts WHERE id=#{Shard.local_id_for(starting_account_id).first}
SELECT * FROM #{Account.quoted_table_name} WHERE id=#{Shard.local_id_for(starting_account_id).first}
UNION
SELECT accounts.* FROM accounts INNER JOIN t ON accounts.id=t.parent_account_id
SELECT accounts.* FROM #{Account.quoted_table_name} INNER JOIN t ON accounts.id=t.parent_account_id
)
SELECT * FROM t
SQL

View File

@ -1709,8 +1709,10 @@ class Assignment < ActiveRecord::Base
}
scope :not_ignored_by, lambda { |user, purpose|
where("NOT EXISTS (SELECT * FROM ignores WHERE asset_type='Assignment' AND asset_id=assignments.id AND user_id=? AND purpose=?)",
user, purpose)
where("NOT EXISTS (?)",
Ignore.where(asset_type: 'Assignment',
user_id: user,
purpose: purpose).where('asset_id=assignments.id'))
}
# the map on the API_NEEDED_FIELDS here is because PostgreSQL will see the

View File

@ -1875,7 +1875,7 @@ class User < ActiveRecord::Base
self.shard.activate do
Shackles.activate(:slave) do
visible_instances = visible_stream_item_instances(opts).
includes(:stream_item => :context).
preload(stream_item: :context).
limit(Setting.get('recent_stream_item_limit', 100))
visible_instances.map do |sii|
si = sii.stream_item