| Line 1645... |
Line 1645... |
| 1645 |
project_name = req.get_param("project_name")
|
1645 |
project_name = req.get_param("project_name")
|
| 1646 |
if project_name == 'accessories':
|
1646 |
if project_name == 'accessories':
|
| 1647 |
jsonReq = json.loads(req.stream.read(), encoding='utf-8')
|
1647 |
jsonReq = json.loads(req.stream.read(), encoding='utf-8')
|
| 1648 |
lgr.info( "Request ----\n" + str(jsonReq))
|
1648 |
lgr.info( "Request ----\n" + str(jsonReq))
|
| 1649 |
self.jsonReq = jsonReq
|
1649 |
self.jsonReq = jsonReq
|
| - |
|
1650 |
self.callType="default"
|
| 1650 |
callLaterAccs = self.callLaterAccs
|
1651 |
callLaterAccs = self.callLaterAccs
|
| 1651 |
accsDisposition = self.accsDisposition
|
1652 |
accsDisposition = self.accsDisposition
|
| 1652 |
self.userId = int(jsonReq.get('user_id'))
|
1653 |
self.userId = int(jsonReq.get('user_id'))
|
| 1653 |
try:
|
1654 |
try:
|
| 1654 |
self.user = session.query(UserCrmCallingData).filter_by(user_id=self.userId).first()
|
1655 |
self.user = session.query(UserCrmCallingData).filter_by(user_id=self.userId).first()
|
| Line 1731... |
Line 1732... |
| 1731 |
else:
|
1732 |
else:
|
| 1732 |
self.user.disposition = 'not_reachable'
|
1733 |
self.user.disposition = 'not_reachable'
|
| 1733 |
self.user.retry_count += 1
|
1734 |
self.user.retry_count += 1
|
| 1734 |
self.user.invalid_retry_count += 1
|
1735 |
self.user.invalid_retry_count += 1
|
| 1735 |
|
1736 |
|
| 1736 |
#retryConfig = session.query(RetryConfig).filter_by(call_type=self.callType, disposition_type=self.retailer.disposition, retry_count=self.retailer.retry_count).first()
|
1737 |
retryConfig = session.query(RetryConfig).filter_by(call_type=self.callType, disposition_type=self.user.disposition, retry_count=self.user.retry_count).first()
|
| 1737 |
#if retryConfig is not None:
|
1738 |
if retryConfig is not None:
|
| 1738 |
#self.user.next_call_time = self.callHistoryCrm.call_time + timedelta(minutes = retryConfig.minutes_ahead)
|
1739 |
self.user.next_call_time = self.callHistoryCrm.call_time + timedelta(minutes = retryConfig.minutes_ahead)
|
| 1739 |
#self.callHistory.disposition_description = 'Call scheduled on ' + datetime.strftime(self.retailer.next_call_time, '%d/%m/%Y %H:%M:%S')
|
1740 |
self.callHistoryCrm.disposition_description = 'Call scheduled on ' + datetime.strftime(self.user.next_call_time, '%d/%m/%Y %H:%M:%S')
|
| 1740 |
#else:
|
1741 |
else:
|
| 1741 |
#self.user.status = 'failed'
|
1742 |
self.user.status = 'failed'
|
| 1742 |
#self.callHistoryCrm.disposition_description = 'Call failed as all attempts exhausted'
|
1743 |
self.callHistoryCrm.disposition_description = 'Call failed as all attempts exhausted'
|
| 1743 |
|
1744 |
|
| 1744 |
session.commit()
|
1745 |
session.commit()
|
| 1745 |
return True
|
1746 |
return True
|
| 1746 |
|
1747 |
|
| 1747 |
def insertUserCrmData(project_id):
|
1748 |
def insertUserCrmData(project_id):
|
| Line 1800... |
Line 1801... |
| 1800 |
break
|
1801 |
break
|
| 1801 |
userPresent = session.query(UserCrmCallingData).filter_by(user_id=userId).order_by(desc(UserCrmCallingData.modified)).first()
|
1802 |
userPresent = session.query(UserCrmCallingData).filter_by(user_id=userId).order_by(desc(UserCrmCallingData.modified)).first()
|
| 1802 |
if userPresent is not None:
|
1803 |
if userPresent is not None:
|
| 1803 |
if userPresent.user_available==1:
|
1804 |
if userPresent.user_available==1:
|
| 1804 |
if userPresent.project_id==projectId:
|
1805 |
if userPresent.project_id==projectId:
|
| 1805 |
print 'Same project Id'
|
- |
|
| 1806 |
continue
|
1806 |
continue
|
| 1807 |
elif userPresent.modified>=(datetime.now().date()-timedelta(days=3)):
|
1807 |
elif userPresent.modified>=(datetime.now().date()-timedelta(days=3)):
|
| 1808 |
print 'Time lag'
|
- |
|
| 1809 |
continue
|
1808 |
continue
|
| - |
|
1809 |
else:
|
| - |
|
1810 |
continue
|
| 1810 |
counter=counter+1
|
1811 |
counter=counter+1
|
| 1811 |
userMasterData = UserCrmCallingData()
|
1812 |
userMasterData = UserCrmCallingData()
|
| 1812 |
userMasterData.user_id = userId
|
1813 |
userMasterData.user_id = userId
|
| 1813 |
userMasterData.name =getUsername(userId)
|
1814 |
userMasterData.name =getUsername(userId)
|
| 1814 |
userMasterData.project_id = projectId
|
1815 |
userMasterData.project_id = projectId
|
| Line 1911... |
Line 1912... |
| 1911 |
|
1912 |
|
| 1912 |
details = session.query(Orders).filter_by(user_id = user.user_id).filter(~Orders.status.in_(['ORDER_NOT_CREATED_KNOWN','ORDER_NOT_CREATED_UNKNOWN', 'ORDER_ALREADY_CREATED_IGNORED'])).order_by(desc(Orders.created)).first()
|
1913 |
details = session.query(Orders).filter_by(user_id = user.user_id).filter(~Orders.status.in_(['ORDER_NOT_CREATED_KNOWN','ORDER_NOT_CREATED_UNKNOWN', 'ORDER_ALREADY_CREATED_IGNORED'])).order_by(desc(Orders.created)).first()
|
| 1913 |
if details is None:
|
1914 |
if details is None:
|
| 1914 |
obj.lastOrderTimestamp =None
|
1915 |
obj.lastOrderTimestamp =None
|
| 1915 |
else:
|
1916 |
else:
|
| 1916 |
print details.created
|
1917 |
obj.last_active =datetime.strftime(details.created, '%d/%m/%Y %H:%M:%S')
|
| 1917 |
obj.totalOrders = session.query(Orders).filter_by(user_id = user.user_id).filter(~Orders.status.in_(['ORDER_NOT_CREATED_KNOWN','ORDER_NOT_CREATED_UNKNOWN', 'ORDER_ALREADY_CREATED_IGNORED'])).count()
|
1918 |
obj.totalOrders = session.query(Orders).filter_by(user_id = user.user_id).filter(~Orders.status.in_(['ORDER_NOT_CREATED_KNOWN','ORDER_NOT_CREATED_UNKNOWN', 'ORDER_ALREADY_CREATED_IGNORED'])).count()
|
| 1918 |
|
1919 |
|
| 1919 |
cartResult = fetchResult("select account_key from user_accounts where account_type ='cartId' and user_id=%d"%(user.user_id))
|
1920 |
cartResult = fetchResult("select account_key from user_accounts where account_type ='cartId' and user_id=%d"%(user.user_id))
|
| 1920 |
if cartResult == ():
|
1921 |
if cartResult == ():
|
| 1921 |
obj.lastActiveCartTime = None
|
1922 |
obj.lastActiveCartTime = None
|