Further improve the media attached status query for accounts (#16106)
This commit is contained in:
		
							parent
							
								
									f78cbc0c32
								
							
						
					
					
						commit
						d0fc69d721
					
				
					 5 changed files with 18 additions and 5 deletions
				
			
		|  | @ -77,7 +77,7 @@ class AccountsController < ApplicationController | |||
|   end | ||||
| 
 | ||||
|   def only_media_scope | ||||
|     Status.joins(:media_attachments).group(:id) | ||||
|     Status.joins(:media_attachments).merge(@account.media_attachments.reorder(nil)).group(:id) | ||||
|   end | ||||
| 
 | ||||
|   def no_replies_scope | ||||
|  |  | |||
|  | @ -14,7 +14,7 @@ module Admin | |||
|       @statuses = @account.statuses.where(visibility: [:public, :unlisted]) | ||||
| 
 | ||||
|       if params[:media] | ||||
|         @statuses.merge!(Status.joins(:media_attachments).group(:id)) | ||||
|         @statuses.merge!(Status.joins(:media_attachments).merge(@account.media_attachments.reorder(nil)).group(:id)) | ||||
|       end | ||||
| 
 | ||||
|       @statuses = @statuses.preload(:media_attachments, :mentions).page(params[:page]).per(PER_PAGE) | ||||
|  |  | |||
|  | @ -42,7 +42,7 @@ class Api::V1::Accounts::StatusesController < Api::BaseController | |||
|   end | ||||
| 
 | ||||
|   def only_media_scope | ||||
|     Status.joins(:media_attachments).group(:id) | ||||
|     Status.joins(:media_attachments).merge(@account.media_attachments.reorder(nil)).group(:id) | ||||
|   end | ||||
| 
 | ||||
|   def pinned_scope | ||||
|  |  | |||
		Reference in a new issue