Skip to content

Commit

Permalink
Seeds (#38)
Browse files Browse the repository at this point in the history
* update seeds

* update seeds
  • Loading branch information
mikeheft authored Jul 7, 2024
1 parent 4834f53 commit 00d4d15
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 17 deletions.
21 changes: 21 additions & 0 deletions .elasticbeanstalk/config.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-3.3.0
3.3.0
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ PLATFORMS
aarch64-linux
arm-linux
arm64-darwin-22
arm64-darwin-23
x86-linux
x86_64-darwin
x86_64-linux
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -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
40 changes: 26 additions & 14 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -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..."
Expand Down

0 comments on commit 00d4d15

Please sign in to comment.