app/controllers/projects_controller.rb
# Subset to only the rows and fields we need
Subset to only the rows and fields we need
Subset to only the rows and fields we need
def select_data_subset
    format = request&.format&.symbol
    if !format || format == :html
      @projects = @projects.select(HTML_INDEX_FIELDS)
    elsif format == :json
      @projects = @projects.includes(:additional_rights)
    end
    @pagy, @projects = pagy(@projects.includes(:user))
    @count = @pagy.count
    @pagy_locale = I18n.locale.to_s 
  end
def select_data_subset format = request &. format &. symbol if ! format || format == :html @projects = @projects . select ( HTML_INDEX_FIELDS ) elsif format == :json @projects = @projects . includes ( :additional_rights ) end @pagy , @projects = pagy ( @projects . includes ( :user ) ) @count = @pagy . count @pagy_locale = I18n . locale . to_s end
Subset to only the rows and fields we need
Subset to only the rows and fields we need
# If we're supplying html (common case), select only needed fields # JSON includes additional_rights; load them at one time to prevent # and N+1 query (do this for CSV also if we ever add that field to CSV) # We want to know the *total* count, even if we're paging. # Pagy has to figure that out anyway, so instead of doing this: # # @count = @projects.count # we will extract it from pagy. # Pagy requires a string version