@@ -7,44 +7,52 @@ def total_count()
7
7
listing_count = Listing . count
8
8
9
9
p "=================TOTAL=================="
10
- p "CLOTHING CATEGORIES CREATED : #{ category_count } "
11
- p "BRANDS CREATED : #{ brand_count } "
12
- p "CONDITIONS CREATED : #{ condition_count } "
13
- p "USERS CREATED : #{ user_count } "
14
- p "LISTING CREATED : #{ listing_count } "
10
+ p "CLOTHING CATEGORIES: #{ category_count } "
11
+ p "BRANDS: #{ brand_count } "
12
+ p "CONDITIONS: #{ condition_count } "
13
+ p "USERS: #{ user_count } "
14
+ p "LISTING: #{ listing_count } "
15
15
p "========================================"
16
16
end
17
17
18
- clothing_category = [ "Accessories" , "Bottoms" , "Headwear" , "Outerwear" , "Shirt" , " T-Shirt" , "Bags "]
19
- brands = [ "Adidas" , "Nike" , "Supreme" , "Off-White" , "Palace" , " Bape" , "Kaws "]
20
- conditions = [ "New with tags" , "New without tags" , "New with box" , "New without box" , "New with defects", "Pre-owned" ]
18
+ clothing_category = [ "Accessories" , "Bottoms" , "Headwear" , "Outerwear" , "T-Shirt" ]
19
+ brands = [ "Adidas" , "Nike" , "Supreme" , "Off-White" , "Bape" ]
20
+ conditions = [ "New with tags" , "New without tags" , "New with defects" , "Pre-owned" ]
21
21
22
22
clothing_category . each do |category |
23
- Category . create (
24
- name : category ,
25
- )
23
+ if Category . exists? ( name : category ) == false
24
+ Category . create (
25
+ name : category ,
26
+ )
27
+ end
26
28
end
27
29
28
30
brands . each do |brand |
29
- Brand . create (
30
- name : brand ,
31
- )
31
+ if Brand . exists? ( name : brand ) == false
32
+ Brand . create (
33
+ name : brand ,
34
+ )
35
+ end
32
36
end
33
37
34
38
conditions . each do |condition |
35
- Condition . create (
36
- name : condition ,
37
- )
39
+ if Condition . exists? ( name : condition ) == false
40
+ Condition . create (
41
+ name : condition ,
42
+ )
43
+ end
38
44
end
39
45
40
46
# Generate test account
41
- User . create (
42
- full_name : "Test Account" ,
43
-
44
- password : "password" ,
45
- password_confirmation : "password" ,
46
- biography : Faker ::Lorem . sentence ( word_count : 3 ) ,
47
- )
47
+ if User . exists? ( full_name :
"Test Account" , email :
"[email protected] " ) ==
false
48
+ User . create (
49
+ full_name : "Test Account" ,
50
+
51
+ password : "password" ,
52
+ password_confirmation : "password" ,
53
+ biography : Faker ::Lorem . sentence ( word_count : 3 ) ,
54
+ )
55
+ end
48
56
49
57
# Generate random user accounts
50
58
for i in 1 ..10
@@ -69,4 +77,14 @@ def total_count()
69
77
)
70
78
end
71
79
80
+ #attach image
81
+ listings = Listing . all
82
+
83
+ listings . each do |listing |
84
+ if listing . brand . name
85
+ random = rand ( 1 ..3 )
86
+ listing . picture . attach ( io : File . open ( "app/assets/images/stock_image/#{ listing . brand . name } /#{ listing . brand . name } _#{ listing . category . name } _#{ random } .png" ) , filename : "#{ listing . brand . name } _#{ listing . category . name } _#{ random } .png" , content_type : "image/png" )
87
+ end
88
+ end
89
+
72
90
total_count ( )
0 commit comments