Skip to content

Commit

Permalink
update seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeheft committed Jul 7, 2024
1 parent 4834f53 commit 6dd0ebd
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 5 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
18 changes: 16 additions & 2 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,38 @@
{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"},
{line_1: "1113 W Plum St", line_2: "Apt 201D", city: "Fort Collins", state: "CO", zip_code: "80512"},
{line_1: "3397 WAGON TRAIL RD", city: "Fort Collins", state: "CO", zip_code: "80524"},
{line_1: "5700 N HIGHWAY 1", city: "Fort Collins", state: "CO", zip_code: "80524"},
{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_1: "3024 SUMAC ST", city: "Fort Collins", state: "CO", zip_code: "80526"},
{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


# Create Drivers
ActiveRecord::Base.connection.transaction do
puts "Creating Drivers..."
3.times do
first_name = Faker::Name.first_name
last_name = Faker::Name.last_name
driver = Driver.build(first_name:,last_name:)
address = Address.create(ADDRESSES.sample)
address = Address.create(**ADDRESSES.sample)
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)
Address.find_or_create_by(line_1: attrs[:line_1], line_2: attrs[:line_2]) do
city = attrs[:city]
state = attrs[:state]
zip_code = attrs[:zip_code]
end
end

puts "Creating Rides..."
Expand Down

0 comments on commit 6dd0ebd

Please sign in to comment.