Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude app usage events table from using window function #3191

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/models/runtime/app_usage_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@ class AppUsageEvent < Sequel::Model
:buildpack_guid, :buildpack_name,
:package_state, :previous_package_state, :parent_app_guid,
:parent_app_name, :process_type, :task_name, :task_guid
AppUsageEvent.dataset_module do
def supports_window_functions?
false
end
end
end
end
20 changes: 20 additions & 0 deletions spec/unit/lib/cloud_controller/paging/sequel_paginator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,26 @@ module VCAP::CloudController
end
end

context 'AppUsageEvents table' do
before do
AppUsageEvent.make(guid: '1', created_at: '2022-12-20T10:47:01Z')
AppUsageEvent.make(guid: '2', created_at: '2022-12-20T10:47:02Z')
AppUsageEvent.make(guid: '3', created_at: '2022-12-20T10:47:03Z')
AppUsageEvent.make(guid: '4', created_at: '2022-12-20T10:47:04Z')
end

it 'does not use window function' do
options = { page: page, per_page: per_page }
pagination_options = PaginationOptions.new(options)

paginated_result = nil
expect {
paginated_result = paginator.get_page(AppUsageEvent.dataset, pagination_options)
}.to have_queried_db_times(/over/i, 0)
expect(paginated_result.total).to be > 1
end
end

it 'returns correct total results for distinct result' do
options = { page: page, per_page: per_page, order_by: :key_name }
pagination_options = PaginationOptions.new(options)
Expand Down