Commit 75e97ffaf4406fd05859a59680cfc999d1889ff0

Authored by Antonio Terceiro
1 parent dff012ca

ActionItem1163: also adding friendships

Showing 1 changed file with 14 additions and 2 deletions   Show diff stats
script/sample-data
@@ -6,7 +6,7 @@ people = [] @@ -6,7 +6,7 @@ people = []
6 NAMES = %w[ José João Antonio Paulo Maria Joana Paula Angela ] 6 NAMES = %w[ José João Antonio Paulo Maria Joana Paula Angela ]
7 SURNAMES = %w[ Silva Santos Abreu Oliveira Machado Bonfim ] 7 SURNAMES = %w[ Silva Santos Abreu Oliveira Machado Bonfim ]
8 User.destroy_all 8 User.destroy_all
9 -print "Creating users: " 9 +print "Creating users: "; $stdout.flush
10 for name in NAMES 10 for name in NAMES
11 for surname in SURNAMES 11 for surname in SURNAMES
12 full_name = [name, surname].join(' ') 12 full_name = [name, surname].join(' ')
@@ -25,10 +25,22 @@ for name in NAMES @@ -25,10 +25,22 @@ for name in NAMES
25 end 25 end
26 puts 26 puts
27 27
  28 +print "Creating some friendships: "; $stdout.flush
  29 +rand(people.size * 3).times do
  30 + from = people.rand
  31 + to = people.rand
  32 + if from != to && !from.friends.include?(to)
  33 + from.add_friend(to)
  34 + end
  35 + print '.'; $stdout.flush
  36 +end
  37 +puts
  38 +
  39 +
28 VERBS = ['Save', 'I like', 'I hate', 'Use'] 40 VERBS = ['Save', 'I like', 'I hate', 'Use']
29 STUFF = ['Free Software', 'Organic food', 'the wales', 'the environment', 'Barack Obama', 'Osama Bin Laden', 'Lula'] 41 STUFF = ['Free Software', 'Organic food', 'the wales', 'the environment', 'Barack Obama', 'Osama Bin Laden', 'Lula']
30 Community.destroy_all 42 Community.destroy_all
31 -print "Creating communities: " 43 +print "Creating communities: "; $stdout.flush
32 for verb in VERBS 44 for verb in VERBS
33 for stuff in STUFF 45 for stuff in STUFF
34 name = [verb, stuff].join(' ') 46 name = [verb, stuff].join(' ')