-
Notifications
You must be signed in to change notification settings - Fork 1
/
script1.py
54 lines (40 loc) · 1.22 KB
/
script1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from foodSite.models import *
import time
import json
from datetime import datetime
def strTimeProp(start, end, format, prop):
stime = time.mktime(time.strptime(start, format))
etime = time.mktime(time.strptime(end, format))
ptime = stime + prop * (etime - stime)
return time.strftime(format, time.localtime(ptime))
def randomDate(start, end, prop):
#YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ]
return strTimeProp(start, end, '%Y-%m-%d %I:%M %p', prop)
mylist=[]
b=1
cust = Customer.objects.all()
food_items=FoodItems.objects.all()
for customer in cust:
print customer.user_id
for fi in food_items:
k=random.randint(0,6)
if k==0:
mydict={}
mydict["model"]="foodSite.OrderHistory"
mydict["pk"]=b
b+=1
field_dict={}
field_dict["food"]=fi.food_id
field_dict["rest"]=fi.rest.rest_id
field_dict["quantity"]=random.randint(1,3)
field_dict["order_id"]=b
field_dict["user"]=customer.user_id
field_dict["status"]="Delivered"
field_dict["order_timestamp"]=str(datetime.now())
field_dict["amount"]=random.randint(200,1000)
field_dict["rating"]=random.uniform(0,5)
mydict["fields"]=field_dict
mylist.append(mydict)
f=open("history.json","wb")
json.dump(mylist,f)
f.close()