| Line 3... |
Line 3... |
| 3 |
from datetime import datetime, timedelta
|
3 |
from datetime import datetime, timedelta
|
| 4 |
from dtr import main
|
4 |
from dtr import main
|
| 5 |
from dtr.config import PythonPropertyReader
|
5 |
from dtr.config import PythonPropertyReader
|
| 6 |
from dtr.storage import Mongo
|
6 |
from dtr.storage import Mongo
|
| 7 |
from dtr.storage.DataService import Retailers, Users, CallHistory, RetryConfig, \
|
7 |
from dtr.storage.DataService import Retailers, Users, CallHistory, RetryConfig, \
|
| 8 |
RetailerLinks, Activation_Codes, Agents,Agent_Roles,AgentLoginTimings
|
8 |
RetailerLinks, Activation_Codes, Agents,Agent_Roles,AgentLoginTimings,\
|
| - |
|
9 |
FetchDataHistory
|
| 9 |
from dtr.utils import FetchLivePrices, DealSheet as X_DealSheet, \
|
10 |
from dtr.utils import FetchLivePrices, DealSheet as X_DealSheet, \
|
| 10 |
UserSpecificDeals
|
11 |
UserSpecificDeals
|
| 11 |
from dtr.utils.utils import getLogger
|
12 |
from dtr.utils.utils import getLogger
|
| 12 |
from elixir import *
|
13 |
from elixir import *
|
| 13 |
from sqlalchemy.sql.expression import or_
|
14 |
from sqlalchemy.sql.expression import or_
|
| Line 605... |
Line 606... |
| 605 |
RETAILER_DETAIL_CALL_COUNTER += 1
|
606 |
RETAILER_DETAIL_CALL_COUNTER += 1
|
| 606 |
lgr.info( "RETAILER_DETAIL_CALL_COUNTER " + str(RETAILER_DETAIL_CALL_COUNTER))
|
607 |
lgr.info( "RETAILER_DETAIL_CALL_COUNTER " + str(RETAILER_DETAIL_CALL_COUNTER))
|
| 607 |
self.agentId = int(agentId)
|
608 |
self.agentId = int(agentId)
|
| 608 |
self.callType = callType
|
609 |
self.callType = callType
|
| 609 |
if retailerId is not None:
|
610 |
if retailerId is not None:
|
| - |
|
611 |
fetchInfo = FetchDataHistory()
|
| - |
|
612 |
fetchInfo.agent_id = self.agentId
|
| - |
|
613 |
fetchInfo.call_type = self.callType
|
| - |
|
614 |
agent = session.query(Agents).filter_by(agent_id=self.agentId).first()
|
| - |
|
615 |
last_disposition = session.query(CallHistory).filter_by(agent_id=self.agentId).order_by(CallHistory.id.desc()).first()
|
| - |
|
616 |
if last_disposition is None or last_disposition.created < agent.last_login:
|
| - |
|
617 |
fetchInfo.last_action = 'login'
|
| - |
|
618 |
fetchInfo.last_action_time = agent.last_login
|
| - |
|
619 |
else:
|
| - |
|
620 |
fetchInfo.last_action = 'disposition'
|
| - |
|
621 |
fetchInfo.last_action_time = last_disposition.created
|
| 610 |
self.retailerId = int(retailerId)
|
622 |
self.retailerId = int(retailerId)
|
| 611 |
retailerLink = session.query(RetailerLinks).filter_by(retailer_id=self.retailerId).first()
|
623 |
retailerLink = session.query(RetailerLinks).filter_by(retailer_id=self.retailerId).first()
|
| 612 |
if retailerLink is not None:
|
624 |
if retailerLink is not None:
|
| 613 |
code = retailerLink.code
|
625 |
code = retailerLink.code
|
| 614 |
else:
|
626 |
else:
|
| Line 666... |
Line 678... |
| 666 |
self.callHistory.disposition_comments = jsonReq.get('calldispositioncomments')
|
678 |
self.callHistory.disposition_comments = jsonReq.get('calldispositioncomments')
|
| 667 |
lgr.info(self.callHistory.disposition_comments)
|
679 |
lgr.info(self.callHistory.disposition_comments)
|
| 668 |
self.callHistory.call_time = datetime.strptime(jsonReq.get("calltime"), '%d/%m/%Y %H:%M:%S')
|
680 |
self.callHistory.call_time = datetime.strptime(jsonReq.get("calltime"), '%d/%m/%Y %H:%M:%S')
|
| 669 |
self.callHistory.mobile_number = jsonReq.get('number')
|
681 |
self.callHistory.mobile_number = jsonReq.get('number')
|
| 670 |
self.callHistory.sms_verified = int(jsonReq.get("verified"))
|
682 |
self.callHistory.sms_verified = int(jsonReq.get("verified"))
|
| - |
|
683 |
lastFetchData = session.query(FetchDataHistory).filter_by(agent_id=self.agentId).order_by(FetchDataHistory.id.desc()).first()
|
| - |
|
684 |
if lastFetchData is None:
|
| - |
|
685 |
raise
|
| - |
|
686 |
self.callHistory.last_fetch_time= lastFetchData.created
|
| 671 |
|
687 |
|
| 672 |
dispositionMap = { 'call_later':callLater,
|
688 |
dispositionMap = { 'call_later':callLater,
|
| 673 |
'ringing_no_answer':callLater,
|
689 |
'ringing_no_answer':callLater,
|
| 674 |
'not_reachable':callLater,
|
690 |
'not_reachable':callLater,
|
| 675 |
'switch_off':callLater,
|
691 |
'switch_off':callLater,
|