Skip to content
This repository has been archived by the owner on Jan 27, 2020. It is now read-only.

Commit

Permalink
Merge pull request mastodon#946 from pixiv/revert-945-remove_direct_q…
Browse files Browse the repository at this point in the history
…uery

Revert "Remove direct query from sitemap"
  • Loading branch information
abcang committed Mar 26, 2018
2 parents ac35bed + 57910f5 commit 0aaf2af
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/pawoo/sitemap/status_indexes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def index

def show
read_from_slave do
@status_pages = Pawoo::Sitemap::Status.new(params[:page]).query.load
@status_pages = Pawoo::Sitemap::Status.new(params[:page]).direct_query.load
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/pawoo/sitemap/user_indexes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def index

def show
read_from_slave do
@accounts = Pawoo::Sitemap::User.new(params[:page]).query.load
@accounts = Pawoo::Sitemap::User.new(params[:page]).direct_query.load
end
end
end
13 changes: 13 additions & 0 deletions app/models/pawoo/sitemap/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ def query
.merge(status_scope).merge(account_scope)
end

# TODO: あとで消す
def direct_query
StreamEntry.joins(:status).joins(status: :account)
.select('statuses.id')
.select('statuses.updated_at')
.select('accounts.username')
.select('statuses.reblogs_count')
.where('stream_entries.id > ?', min_id)
.where('stream_entries.id <= ?', max_id)
.where(hidden: false)
.merge(status_scope).merge(account_scope)
end

def prepare
status_ids = StreamEntry.joins(:status).joins(status: :account)
.where('stream_entries.id > ?', min_id)
Expand Down
8 changes: 8 additions & 0 deletions app/models/pawoo/sitemap/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def query
Account.where(id: account_ids).merge(account_scope)
end

# TODO: あとで消す
def direct_query
Account.joins(:user)
.where('users.id > ?', min_id)
.where('users.id <= ?', max_id)
.merge(account_scope)
end

def prepare
account_ids = ::User.joins(:account)
.where('users.id > ?', min_id)
Expand Down

0 comments on commit 0aaf2af

Please sign in to comment.