Skip to content

Commit 1549d5b

Browse files
committed
Update demo data to use groups
1 parent e8f9e70 commit 1549d5b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/tasks/populate.rake

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace :db do
1010
number_threads = rand(20..50)
1111
number_tickets = rand(20..50)
1212

13+
groups = [[0, ''],[1, 'equipment'],[2, 'onboarding'],[3, 'billing'],[4, '']]
14+
1315
unless User.where(email: 'admin@test.com')
1416
admin_user = User.create!(name: 'Admin', login:'admin', email: 'admin@test.com', password:'12345678', admin: true)
1517
puts "Created Admin: #{admin_user.name}"
@@ -19,15 +21,15 @@ namespace :db do
1921
company = RUser.new
2022
company_name = "#{Faker::Hacker.noun} #{Faker::Hacker.ingverb} #{company_type}"
2123

22-
number_support_team.times do
24+
number_support_team.times.each_with_index do |item, index|
2325
user = RUser.new
2426
u = User.create(
2527
name: "#{user.first_name} #{user.last_name}",
2628
email: user.email,
2729
login: user.username,
2830
password: '12345678',
2931
admin: true,
30-
role: 'admin',
32+
role: 'agent',
3133
company: company_name,
3234
street: company.street,
3335
city: company.city,
@@ -37,9 +39,9 @@ namespace :db do
3739
cell_phone: user.cell,
3840
thumbnail: user.profile_thumbnail_url,
3941
medium_image: user.profile_medium_url,
40-
large_image: user.profile_large_url
42+
large_image: user.profile_large_url,
43+
team_list: groups[index][1]
4144
)
42-
4345
puts "Created Agent: #{u.name}"
4446
end
4547

@@ -197,7 +199,7 @@ namespace :db do
197199

198200
# Create back and forth private threads with support staff
199201
f = Forum.find(1)
200-
number_tickets.times do
202+
number_tickets.times.each_with_index do |item, index|
201203

202204
timeseed = rand(1..30)
203205
Timecop.travel(Date.today-timeseed.days)
@@ -209,7 +211,8 @@ namespace :db do
209211
name: question,
210212
user_id: User.where(admin: false).sample.id,
211213
private: true,
212-
assigned_user_id: User.where(admin: true).sample.id
214+
assigned_user_id: User.where(admin: true).sample.id,
215+
team_list: groups.sample[1]
213216
)
214217

215218
# create first post in thread

0 commit comments

Comments
 (0)