From 9464df8aaee976afe81c447d7e93194dbc1dc680 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 10 May 2024 14:09:49 +1000 Subject: [PATCH 1/3] Remove obsolete Enterprise#distributor_info --- ...40510040639_remove_distributor_info_from_enterprises.rb | 7 +++++++ db/schema.rb | 3 +-- lib/tasks/enterprises.rake | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20240510040639_remove_distributor_info_from_enterprises.rb diff --git a/db/migrate/20240510040639_remove_distributor_info_from_enterprises.rb b/db/migrate/20240510040639_remove_distributor_info_from_enterprises.rb new file mode 100644 index 0000000000..3ead73c8a7 --- /dev/null +++ b/db/migrate/20240510040639_remove_distributor_info_from_enterprises.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class RemoveDistributorInfoFromEnterprises < ActiveRecord::Migration[7.0] + def change + remove_column :enterprises, :distributor_info, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 1cbb2938fa..11699763ba 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.0].define(version: 2024_05_01_075735) do +ActiveRecord::Schema[7.0].define(version: 2024_05_10_040639) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "plpgsql" @@ -208,7 +208,6 @@ ActiveRecord::Schema[7.0].define(version: 2024_05_01_075735) do t.string "next_collection_at", limit: 255 t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false - t.text "distributor_info" t.string "facebook", limit: 255 t.string "instagram", limit: 255 t.string "linkedin", limit: 255 diff --git a/lib/tasks/enterprises.rake b/lib/tasks/enterprises.rake index bc97529547..7c2696448c 100644 --- a/lib/tasks/enterprises.rake +++ b/lib/tasks/enterprises.rake @@ -32,7 +32,7 @@ namespace :ofn do def enterprise_header ['name', 'description', 'long_description', 'is_primary_producer', 'is_distributor', 'contact_name', 'phone', 'email', 'website', 'twitter', 'abn', 'acn', 'pickup_times', - 'next_collection_at', 'distributor_info', 'visible', 'facebook', 'instagram', 'linkedin', + 'next_collection_at', 'visible', 'facebook', 'instagram', 'linkedin', 'address1', 'address2', 'city', 'zipcode', 'state', 'country'] end @@ -41,7 +41,7 @@ namespace :ofn do enterprise.is_primary_producer, enterprise.is_distributor, enterprise.contact_name, enterprise.phone, enterprise.email, enterprise.website, enterprise.twitter, enterprise.abn, enterprise.acn, enterprise.pickup_times, enterprise.next_collection_at, - enterprise.distributor_info, enterprise.visible, enterprise.facebook, enterprise.instagram, + enterprise.visible, enterprise.facebook, enterprise.instagram, enterprise.linkedin, enterprise.address.address1, enterprise.address.address2, enterprise.address.city, enterprise.address.zipcode, enterprise.address.state_name, enterprise.address.country&.name] From c981661fe0abd2d84c858e8ae03aa4714c46dd5b Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 10 May 2024 14:12:26 +1000 Subject: [PATCH 2/3] Remove obsolete Enterprise#pickup_times --- .../20240510041114_remove_pickup_times_from_enterprises.rb | 7 +++++++ db/schema.rb | 3 +-- lib/tasks/enterprises.rake | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20240510041114_remove_pickup_times_from_enterprises.rb diff --git a/db/migrate/20240510041114_remove_pickup_times_from_enterprises.rb b/db/migrate/20240510041114_remove_pickup_times_from_enterprises.rb new file mode 100644 index 0000000000..bfe62525a6 --- /dev/null +++ b/db/migrate/20240510041114_remove_pickup_times_from_enterprises.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class RemovePickupTimesFromEnterprises < ActiveRecord::Migration[7.0] + def change + remove_column :enterprises, :pickup_times, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 11699763ba..90f54fd79a 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.0].define(version: 2024_05_10_040639) do +ActiveRecord::Schema[7.0].define(version: 2024_05_10_041114) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "plpgsql" @@ -204,7 +204,6 @@ ActiveRecord::Schema[7.0].define(version: 2024_05_10_040639) do t.string "abn", limit: 255 t.string "acn", limit: 255 t.integer "address_id" - t.text "pickup_times" t.string "next_collection_at", limit: 255 t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false diff --git a/lib/tasks/enterprises.rake b/lib/tasks/enterprises.rake index 7c2696448c..9dd85acd2f 100644 --- a/lib/tasks/enterprises.rake +++ b/lib/tasks/enterprises.rake @@ -31,7 +31,7 @@ namespace :ofn do def enterprise_header ['name', 'description', 'long_description', 'is_primary_producer', 'is_distributor', - 'contact_name', 'phone', 'email', 'website', 'twitter', 'abn', 'acn', 'pickup_times', + 'contact_name', 'phone', 'email', 'website', 'twitter', 'abn', 'acn', 'next_collection_at', 'visible', 'facebook', 'instagram', 'linkedin', 'address1', 'address2', 'city', 'zipcode', 'state', 'country'] end @@ -40,7 +40,7 @@ namespace :ofn do [enterprise.name, enterprise.description, enterprise.long_description, enterprise.is_primary_producer, enterprise.is_distributor, enterprise.contact_name, enterprise.phone, enterprise.email, enterprise.website, enterprise.twitter, enterprise.abn, - enterprise.acn, enterprise.pickup_times, enterprise.next_collection_at, + enterprise.acn, enterprise.next_collection_at, enterprise.visible, enterprise.facebook, enterprise.instagram, enterprise.linkedin, enterprise.address.address1, enterprise.address.address2, enterprise.address.city, enterprise.address.zipcode, enterprise.address.state_name, From 135128cf4126bb6481a60c64af524e0b96e6e258 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 10 May 2024 14:19:42 +1000 Subject: [PATCH 3/3] Remove obsolete Enterprise#next_collection_at This was actually shown in one place and represents a user-facing change. But you weren't able to edit the field which means that only very old enterprises would have had this field set and were not able to change it anymore. I searched au-prod and found the following values in the database: - "Friday 31st January" - "From 4pm, Monday 30 September" - "From 5pm-7pm Monday" - "Saturday 27 April 12noon" - "January 31st/February 1st" - "Saturday 1st February" They seem specific to a certain order cycle and have no value as fallback any more. Seems safe to remove. --- app/models/order_cycle.rb | 2 +- app/views/spree/orders/edit.html.haml | 2 -- ...510041829_remove_next_collection_at_from_enterprises.rb | 7 +++++++ lib/tasks/enterprises.rake | 4 ++-- spec/models/order_cycle_spec.rb | 6 +----- 5 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 db/migrate/20240510041829_remove_next_collection_at_from_enterprises.rb diff --git a/app/models/order_cycle.rb b/app/models/order_cycle.rb index 7b71a3a79e..060f75e4f0 100644 --- a/app/models/order_cycle.rb +++ b/app/models/order_cycle.rb @@ -253,7 +253,7 @@ class OrderCycle < ApplicationRecord end def pickup_time_for(distributor) - exchange_for_distributor(distributor)&.pickup_time || distributor.next_collection_at + exchange_for_distributor(distributor)&.pickup_time end def pickup_instructions_for(distributor) diff --git a/app/views/spree/orders/edit.html.haml b/app/views/spree/orders/edit.html.haml index fb50b995eb..30811833b9 100644 --- a/app/views/spree/orders/edit.html.haml +++ b/app/views/spree/orders/edit.html.haml @@ -13,8 +13,6 @@ %strong - if @order.order_cycle = pickup_time @order.order_cycle - - else - = @order.distributor.next_collection_at - content_for :ordercycle_sidebar do .show-for-large-up.large-4.columns diff --git a/db/migrate/20240510041829_remove_next_collection_at_from_enterprises.rb b/db/migrate/20240510041829_remove_next_collection_at_from_enterprises.rb new file mode 100644 index 0000000000..bce671833f --- /dev/null +++ b/db/migrate/20240510041829_remove_next_collection_at_from_enterprises.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class RemoveNextCollectionAtFromEnterprises < ActiveRecord::Migration[7.0] + def change + remove_column :enterprises, :next_collection_at, :string + end +end diff --git a/lib/tasks/enterprises.rake b/lib/tasks/enterprises.rake index 9dd85acd2f..fa735853c2 100644 --- a/lib/tasks/enterprises.rake +++ b/lib/tasks/enterprises.rake @@ -32,7 +32,7 @@ namespace :ofn do def enterprise_header ['name', 'description', 'long_description', 'is_primary_producer', 'is_distributor', 'contact_name', 'phone', 'email', 'website', 'twitter', 'abn', 'acn', - 'next_collection_at', 'visible', 'facebook', 'instagram', 'linkedin', + 'visible', 'facebook', 'instagram', 'linkedin', 'address1', 'address2', 'city', 'zipcode', 'state', 'country'] end @@ -40,7 +40,7 @@ namespace :ofn do [enterprise.name, enterprise.description, enterprise.long_description, enterprise.is_primary_producer, enterprise.is_distributor, enterprise.contact_name, enterprise.phone, enterprise.email, enterprise.website, enterprise.twitter, enterprise.abn, - enterprise.acn, enterprise.next_collection_at, + enterprise.acn, enterprise.visible, enterprise.facebook, enterprise.instagram, enterprise.linkedin, enterprise.address.address1, enterprise.address.address2, enterprise.address.city, enterprise.address.zipcode, enterprise.address.state_name, diff --git a/spec/models/order_cycle_spec.rb b/spec/models/order_cycle_spec.rb index 39095af2f6..b673da05e9 100644 --- a/spec/models/order_cycle_spec.rb +++ b/spec/models/order_cycle_spec.rb @@ -272,7 +272,7 @@ RSpec.describe OrderCycle do @oc = create(:simple_order_cycle) @d1 = create(:enterprise) - @d2 = create(:enterprise, next_collection_at: '2-8pm Friday') + @d2 = create(:enterprise) @e0 = create(:exchange, order_cycle: @oc, sender: create(:enterprise), receiver: @oc.coordinator, incoming: true) @@ -292,10 +292,6 @@ RSpec.describe OrderCycle do it "looks up the pickup time on the exchange when present" do expect(@oc.pickup_time_for(@d1)).to eq('5pm Tuesday') end - - it "returns the distributor's default collection time otherwise" do - expect(@oc.pickup_time_for(@d2)).to eq('2-8pm Friday') - end end describe "finding pickup instructions for a distributor" do