-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_examples.py
More file actions
executable file
·103 lines (78 loc) · 2.4 KB
/
make_examples.py
File metadata and controls
executable file
·103 lines (78 loc) · 2.4 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#! /usr/bin/env python3
import json
import random
import sys
from datetime import date, datetime, timedelta
from typing import Union
# import lorem
num_accounts = 9
onehour = 60 * 60 # in seconds
oneday = 24 * onehour # in seconds
# now = round(datetime.now().timestamp())
# times = [x for x in range(oneday, 10 * oneday, onehour)]
timers_per_day = [2, 3, 4, 5]
length_timer = []
names = [
"Johnson, Noah",
"Williams, Oliver",
"Brown, James",
"Jones, Theodore",
"Miller, Henry",
"Davis, Lucas",
"Smith, William",
]
accounts = []
for name in names:
accounts.append({"account_name": name})
memos = ["phone", "meeting", "research", "travel"]
DAY = timedelta(days=1)
def begMonth(dt: datetime):
"""Return the first day of the month of the provided datetime."""
return datetime.strptime(dt.strftime("%Y-%m") + "-01", "%Y-%m-%d")
def prevMonth(dt: datetime):
"""Return the first day of the previous month of the provided datetime."""
active_month = dt.strftime("%Y-%m")
dt = begMonth(dt) - DAY
return begMonth(dt)
last_date = datetime.now()
start_date = prevMonth(prevMonth(begMonth(last_date)))
start_minutes = 9 * 60 # 09:00H
end_minutes = 17 * 60 # 17:00H
idle_minutes = [x for x in range(12, 91, 1)]
timer_minutes = [x for x in range(24, 85, 1)]
times = []
dt = start_date
while dt < last_date:
num_timers = random.choice(timers_per_day)
start = dt + timedelta(minutes=start_minutes)
for timer in range(num_timers):
memo = random.choice(memos)
account_name = random.choice(names)
account_id = names.index(account_name)
start += timedelta(minutes=random.choice(idle_minutes))
extent = timedelta(minutes=random.choice(timer_minutes))
start += extent
times.append(
{
"account_name": account_name,
"memo": memo,
"timedelta": round(extent.total_seconds()),
"datetime": round(start.timestamp()),
}
)
dt += DAY
data = {"accounts": accounts, "times": times}
# print(data)
def make_examples(egfile: str):
if egfile:
with open(egfile, "w") as json_file:
json.dump(data, json_file, indent=3)
return data
if __name__ == "__main__":
if len(sys.argv) > 1:
egfile = sys.argv.pop(1)
else:
egfile = None
res = make_examples(egfile)
for _ in res:
print(_)