@@ -201,17 +201,17 @@ def generate_purchases(fake: Faker, user: any, purchases_count: int) -> list[Dic
201
201
purchases : list [Dict ] = []
202
202
purchase_percent_remaining = 80 # ~ 20% of people will have no purchases
203
203
total_products = len (generate_products ())
204
- purchase_percent_remaining = purchase_percent_remaining - random .randrange (0 , 100 )
204
+ purchase_percent_remaining = purchase_percent_remaining - random .randrange (1 , 100 )
205
205
i = 0
206
206
while purchase_percent_remaining > 0 :
207
207
id = purchases_count + i + 1
208
- product_id = random .randrange (0 , total_products )
208
+ product_id = random .randrange (1 , total_products )
209
209
added_to_cart_at = random_date_in_range (user ["created_at" ])
210
210
purchased_at = (
211
- random_date_in_range (added_to_cart_at ) if added_to_cart_at is not None and random .randrange (0 , 100 ) <= 70 else None
211
+ random_date_in_range (added_to_cart_at ) if added_to_cart_at is not None and random .randrange (1 , 100 ) <= 70 else None
212
212
) # 70% likely to purchase the item in the cart
213
213
returned_at = (
214
- random_date_in_range (purchased_at ) if purchased_at is not None and random .randrange (0 , 100 ) <= 30 else None
214
+ random_date_in_range (purchased_at ) if purchased_at is not None and random .randrange (1 , 100 ) <= 30 else None
215
215
) # 10% likely to return the item
216
216
purchase = {
217
217
"id" : id ,
@@ -223,7 +223,7 @@ def generate_purchases(fake: Faker, user: any, purchases_count: int) -> list[Dic
223
223
}
224
224
purchases .append (purchase )
225
225
226
- purchase_percent_remaining = purchase_percent_remaining - random .randrange (0 , 100 )
226
+ purchase_percent_remaining = purchase_percent_remaining - random .randrange (1 , 100 )
227
227
i = i + 1
228
228
return purchases
229
229
0 commit comments