From 00d4d15aa23bf81ef60df5ee2e74f2c7ac35df6a Mon Sep 17 00:00:00 2001 From: Mike Heft Date: Sun, 7 Jul 2024 16:42:40 -0600 Subject: [PATCH] Seeds (#38) * update seeds * update seeds --- .elasticbeanstalk/config.yml | 21 ++++++++++++ .ruby-version | 2 +- Gemfile.lock | 1 + app/controllers/application_controller.rb | 6 ++-- db/seeds.rb | 40 +++++++++++++++-------- 5 files changed, 53 insertions(+), 17 deletions(-) create mode 100644 .elasticbeanstalk/config.yml diff --git a/.elasticbeanstalk/config.yml b/.elasticbeanstalk/config.yml new file mode 100644 index 0000000..f7b4d2c --- /dev/null +++ b/.elasticbeanstalk/config.yml @@ -0,0 +1,21 @@ +branch-defaults: + actions: + environment: prod-env + main: + environment: prod-env +environment-defaults: + prod-env: + branch: null + repository: null +global: + application_name: hop-skip-drive-test + default_ec2_keyname: null + default_platform: Ruby 3.2 running on 64bit Amazon Linux 2023 + default_region: us-west-2 + include_git_submodules: true + instance_profile: null + platform_name: null + platform_version: null + profile: null + sc: git + workspace_type: Application diff --git a/.ruby-version b/.ruby-version index 03463f3..0fa4ae4 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-3.3.0 +3.3.0 \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 6cbda39..7dbc7c0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -325,6 +325,7 @@ PLATFORMS aarch64-linux arm-linux arm64-darwin-22 + arm64-darwin-23 x86-linux x86_64-darwin x86_64-linux diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index aadf6ca..88e70a9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,14 +1,16 @@ # frozen_string_literal: true +# rubocop:disable Lint/RedundantSafeNavigation class ApplicationController < ActionController::API private def pagination_params params.permit(:limit, :offset) end private def limit - pagination_params[:limit] || 2 + pagination_params[:limit]&.to_i || 2 end private def offset - pagination_params[:offset] || 0 + pagination_params[:offset]&.to_i || 0 end end +# rubocop:enable Lint/RedundantSafeNavigation diff --git a/db/seeds.rb b/db/seeds.rb index 0126b70..28aba90 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,31 +1,43 @@ -ADDRESSES = [ - {line_1:"1221 E Elizabeth St", city: "Fort Collins", state: "CO", zip_code: "80524"}, - {line_1:"2121 E Harmony Rd # 180", city: "Fort Collins", state: "CO", zip_code: "80528"}, - {line_1:"2315 E Harmony Rd Suite 110", city: "Fort Collins", state: "CO", zip_code: "80528"}, - {line_1:"608 E Harmony Rd #101", city: "Fort Collins", state: "CO", zip_code: "80525"}, - {line_1:"1106 E Prospect Rd", city: "Fort Collins", state: "CO", zip_code: "80525"}, - {line_1:"1939 Wilmington Dr", city: "Fort Collins", state: "CO", zip_code: "80528"}, - {line_1:"1107 S Lemay Ave", line_2: "Suite 240", city: "Fort Collins", state: "CO", zip_code: "80524"}, - {line_1:"1024 S Lemay Ave", city: "Fort Collins", state: "CO", zip_code: "80524"}, - {line_1:"4601 Corbett Dr", city: "Fort Collins", state: "CO", zip_code: "80528"}, +ADDRESSES = [{:line_1=>"1221 E Elizabeth St", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80524", :line_2=>nil}, + {:line_1=>"2121 E Harmony Rd # 180", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80528", :line_2=>nil}, + {:line_1=>"2315 E Harmony Rd Suite 110", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80528", :line_2=>nil}, + {:line_1=>"608 E Harmony Rd #101", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80525", :line_2=>nil}, + {:line_1=>"1106 E Prospect Rd", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80525", :line_2=>nil}, + {:line_1=>"1939 Wilmington Dr", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80528", :line_2=>nil}, + {:line_1=>"1107 S Lemay Ave", :line_2=>"Suite 240", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80524"}, + {:line_1=>"1024 S Lemay Ave", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80524", :line_2=>nil}, + {:line_1=>"4601 Corbett Dr", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80528", :line_2=>nil}, + {:line_1=>"1113 W Plum St", :line_2=>"Apt 201 D", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80512"}, + {:line_1=>"3397 Wagon Trail Rd", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80524", :line_2=>nil}, + {:line_1=>"5700 N Highway 1", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80524", :line_2=>nil}, + {:line_1=>"6609 Desert Willow Way", :line_2=>"Unit 1", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80525"}, + {:line_1=>"2002 Battlecreek Dr", :line_2=>"Apt 6303", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80528"}, + {:line_1=>"1901 Yorktown Ave", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80526", :line_2=>nil}, + {:line_1=>"3024 Sumac St", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80526", :line_2=>nil}, + {:line_1=>"700 E Drake Rd", :line_2=>"Apt P08", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80525"}, + {:line_1=>"333 Riva Ridge Dr", :line_2=>"Apt C201", :city=>"Fort Collins", :state=>"Co", :zip_code=>"80526"}].freeze + +def create_address(**attrs) + Address.find_or_create_by(**attrs) +end -].freeze # Create Drivers ActiveRecord::Base.connection.transaction do puts "Creating Drivers..." - 3.times do + 3.times do |i| first_name = Faker::Name.first_name last_name = Faker::Name.last_name driver = Driver.build(first_name:,last_name:) - address = Address.create(ADDRESSES.sample) + attrs = ADDRESSES[i] + address = create_address(**attrs) driver.driver_addresses.build(address_id: address.id, current: true) driver.save! end puts "Creating remaining Addresses..." ADDRESSES[(Address.count + 1)..].each do |attrs| - Address.create(**attrs) + create_address(**attrs) end puts "Creating Rides..."