-
Notifications
You must be signed in to change notification settings - Fork 0
/
logic.py
executable file
·24 lines (22 loc) · 983 Bytes
/
logic.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
import datetime
from updater import updateStage
from duration import getDuration
def checkData(clientData):
for data in clientData:
dealID = data["id"]
stageID = data["stage_id"]
clientName = data["person_id"]["name"]
print(f"Checking for {clientName} with deal ID : {dealID}")
if stageID == 2 or stageID == 3:
stageChangeTime = datetime.datetime.strptime(clientData[0]["stage_change_time"], "%Y-%m-%d %H:%M:%S")
duration = getDuration(stageChangeTime)
print(f"Deal has been in this stage for {duration} hours")
if duration >= 48:
print("Update Required")
stageID = stageID+1
print(f"Updating stage from {stage-1} to {stage}...")
updateStage(dealID, stageID, clientName)
else:
print("Not completed 48 hours in the stage")
else:
print(f"Stage is {stageID}, Update not required")