-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathrecovery_time.py
41 lines (29 loc) · 942 Bytes
/
recovery_time.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
from dataclasses import dataclass
def find_outages(deployments):
results = []
for patch_split in split_sequence(deployments):
first_patch = patch_split[0]
deployment_index = deployments.index(first_patch) - 1
if deployment_index >= 0:
failed_deployment = deployments[deployment_index]
last_patch = patch_split[-1]
results.append((failed_deployment, last_patch))
return results
def split_sequence(deployments):
split = []
for deployment in deployments:
if deployment.is_patch:
split.append(deployment)
else:
if split:
yield split
split = []
if split:
yield split
def find_is_patch(deployment_name, deploy_tags, patch_dates):
deploy_date = deploy_tags[deployment_name]
return deploy_date in patch_dates
@dataclass
class Deployment:
is_patch: bool
time: int