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

[CPDNPQ-2395] improve participants API load times #2101

Merged
merged 3 commits into from
Jan 13, 2025
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
2 changes: 1 addition & 1 deletion app/controllers/concerns/api/pagination.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Pagination
private

def paginate(scope)
_pagy, paginated_records = pagy(scope, limit: per_page, page:)
_pagy, paginated_records = pagy_countless(scope, limit: per_page, page:)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL about Pagy::Countless 💡


paginated_records
end
Expand Down
1 change: 1 addition & 0 deletions config/initializers/pagy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require "pagy/extras/countless"
require "pagy/extras/overflow"

Pagy::DEFAULT[:size] = [1, 1, 1, 1]
Expand Down
6 changes: 6 additions & 0 deletions db/migrate/20250103111630_add_indexes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddIndexes < ActiveRecord::Migration[7.1]
def change
add_index :applications, %i[lead_provider_approval_status lead_provider_id]
add_index :users, :created_at
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_12_18_101840) do
ActiveRecord::Schema[7.1].define(version: 2025_01_03_111630) do
# These are extensions that must be enabled in order to support this database
enable_extension "btree_gin"
enable_extension "citext"
Expand Down Expand Up @@ -119,6 +119,7 @@
t.index ["course_id"], name: "index_applications_on_course_id"
t.index ["ecf_id"], name: "index_applications_on_ecf_id", unique: true
t.index ["itt_provider_id"], name: "index_applications_on_itt_provider_id"
t.index ["lead_provider_approval_status", "lead_provider_id"], name: "idx_on_lead_provider_approval_status_lead_provider__299e5bac06"
t.index ["lead_provider_id"], name: "index_applications_on_lead_provider_id"
t.index ["private_childcare_provider_id"], name: "index_applications_on_private_childcare_provider_id"
t.index ["schedule_id"], name: "index_applications_on_schedule_id"
Expand Down Expand Up @@ -537,6 +538,7 @@
t.string "archived_email"
t.datetime "archived_at"
t.datetime "significantly_updated_at", default: -> { "CURRENT_TIMESTAMP" }, null: false
t.index ["created_at"], name: "index_users_on_created_at"
t.index ["ecf_id"], name: "index_users_on_ecf_id", unique: true
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["provider"], name: "index_users_on_provider"
Expand Down
Loading