Skip to content

Commit

Permalink
Fix paths for random_data generation script
Browse files Browse the repository at this point in the history
  • Loading branch information
luisbelloch committed Feb 7, 2019
1 parent 1e37851 commit 379c314
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions data/random_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def credit_card
end

def funds(m)
(1..m).each do |n|
(1..m).each do |n|
amount = Random.rand(1000.0)
parent = gen_id
parent_name = Faker::Company.name
Expand All @@ -42,8 +42,8 @@ def ratings(m)

def ships_and_containers(m, p)
puts ['ship_imo', 'ship_name', 'country', 'departure', 'container_id', 'container_type', 'container_group', 'net_weight', 'gross_weight', 'owner', 'declared', 'contact', 'customs_ok'].join(";")
container_codes = CSV.read('./data/iso-container-codes.csv').map { |m| m[0] }.drop(1)
container_groups = CSV.read('./data/iso-container-groups.csv').map { |m| m[0] }.drop(1)
container_codes = CSV.read('./iso-container-codes.csv').map { |m| m[0] }.drop(1)
container_groups = CSV.read('./iso-container-groups.csv').map { |m| m[0] }.drop(1)
(1..m).each do |n|
ship_imo = gen_id(3, 1000000)
ship_name = [Faker::Name.first_name, Faker::Address.city].sample
Expand All @@ -70,22 +70,22 @@ def ships_and_containers(m, p)

def shop(m)
puts ['tx_id', 'tx_time', 'buyer', 'currency_code', 'payment_type', 'credit_card_number', 'country', 'department', 'product', 'item_price', 'coupon_code', 'was_returned'].join('|')
(1..m).each do |n|
(1..m).each do |n|
buyer = Faker::Name.name
tx_id = gen_id(7, 100)
tx_time = time_rand Time.local(2010, 1, 1), Time.local(2010, 12, 31)
cc = credit_card()
price = Faker::Commerce.price
currency = ['USD', 'EUR', 'JPY', 'AUD', 'CAD', 'GBP'].sample
payment = ['VISA', 'MASTERCARD', 'AMERICAN_EXPRESS', 'DANKORT', 'JCB', 'FORBRUGSFORENINGEN'].sample
payment = ['VISA', 'MASTERCARD', 'AMERICAN_EXPRESS', 'DANKORT', 'JCB', 'FORBRUGSFORENINGEN'].sample
country = Faker::Address.country_code
divisions = [0, 0, Random.rand(5)].sample
positions = [0] + (0..divisions-1).map { |d| Random.rand(1.0) }.sort + [1]
positions.each_cons(2) do |pos|
percent = pos[1] - pos[0]
item_price = (price*percent).round(2)
department = Faker::Commerce.department(1, true)
product = Faker::Commerce.product_name
product = Faker::Commerce.product_name
coupon = [false, false, true, false].sample
coupon_code = ''
if (coupon)
Expand All @@ -100,4 +100,4 @@ def shop(m)

# shop(1000)
# ships_and_containers(20, 2)
ratings(10000)
# ratings(10000)

0 comments on commit 379c314

Please sign in to comment.