diff --git a/app/controllers/distributions_controller.rb b/app/controllers/distributions_controller.rb index 4a748de7ff..8cd70a2c4f 100644 --- a/app/controllers/distributions_controller.rb +++ b/app/controllers/distributions_controller.rb @@ -225,7 +225,14 @@ def itemized_breakdown # TODO: This needs a little more context. Is it JSON only? HTML? def schedule - @pick_ups = current_organization.distributions + respond_to do |format| + format.html + format.json do + start_at = params[:start].to_datetime + end_at = params[:end].to_datetime + @pick_ups = current_organization.distributions.includes(:partner).where(issued_at: start_at..end_at) + end + end end def calendar diff --git a/db/migrate/20240711020808_add_issued_at_index_to_distribution.rb b/db/migrate/20240711020808_add_issued_at_index_to_distribution.rb new file mode 100644 index 0000000000..05f43f895f --- /dev/null +++ b/db/migrate/20240711020808_add_issued_at_index_to_distribution.rb @@ -0,0 +1,7 @@ +class AddIssuedAtIndexToDistribution < ActiveRecord::Migration[7.1] + disable_ddl_transaction! + + def change + add_index :distributions, :issued_at, algorithm: :concurrently + end +end diff --git a/db/schema.rb b/db/schema.rb index 8cf2594a08..630f84f4e1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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_07_04_214509) do +ActiveRecord::Schema[7.1].define(version: 2024_07_11_020808) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -244,6 +244,7 @@ t.boolean "reminder_email_enabled", default: false, null: false t.integer "delivery_method", default: 0, null: false t.decimal "shipping_cost", precision: 8, scale: 2 + t.index ["issued_at"], name: "index_distributions_on_issued_at" t.index ["organization_id"], name: "index_distributions_on_organization_id" t.index ["partner_id"], name: "index_distributions_on_partner_id" t.index ["storage_location_id"], name: "index_distributions_on_storage_location_id"