Commit 75e97ffaf4406fd05859a59680cfc999d1889ff0
1 parent
dff012ca
Exists in
master
and in
22 other branches
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 | 6 | NAMES = %w[ José João Antonio Paulo Maria Joana Paula Angela ] |
| 7 | 7 | SURNAMES = %w[ Silva Santos Abreu Oliveira Machado Bonfim ] |
| 8 | 8 | User.destroy_all |
| 9 | -print "Creating users: " | |
| 9 | +print "Creating users: "; $stdout.flush | |
| 10 | 10 | for name in NAMES |
| 11 | 11 | for surname in SURNAMES |
| 12 | 12 | full_name = [name, surname].join(' ') |
| ... | ... | @@ -25,10 +25,22 @@ for name in NAMES |
| 25 | 25 | end |
| 26 | 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 | 40 | VERBS = ['Save', 'I like', 'I hate', 'Use'] |
| 29 | 41 | STUFF = ['Free Software', 'Organic food', 'the wales', 'the environment', 'Barack Obama', 'Osama Bin Laden', 'Lula'] |
| 30 | 42 | Community.destroy_all |
| 31 | -print "Creating communities: " | |
| 43 | +print "Creating communities: "; $stdout.flush | |
| 32 | 44 | for verb in VERBS |
| 33 | 45 | for stuff in STUFF |
| 34 | 46 | name = [verb, stuff].join(' ') | ... | ... |