| Line 66... |
Line 66... |
| 66 |
logging.debug('Completed')
|
66 |
logging.debug('Completed')
|
| 67 |
|
67 |
|
| 68 |
def handleCampaignRequest(threadName, recordsList ):
|
68 |
def handleCampaignRequest(threadName, recordsList ):
|
| 69 |
for record in recordsList:
|
69 |
for record in recordsList:
|
| 70 |
userGcmRegIdDetails = userGcmRegIdMap.get(long(record.get('user_id')))
|
70 |
userGcmRegIdDetails = userGcmRegIdMap.get(long(record.get('user_id')))
|
| 71 |
campaign = notificationCampaignsMap.get(record.get('notification_campaign_id'))
|
71 |
campaign = notificationCampaignsMap.get(long(record.get('notification_campaign_id')))
|
| 72 |
gcm_id = record.get('gcm_id')
|
72 |
gcm_id = record.get('gcm_id')
|
| 73 |
detailsMap = userGcmRegIdDetails.get(gcm_id)
|
73 |
detailsMap = userGcmRegIdDetails.get(gcm_id)
|
| 74 |
result_url = ""
|
74 |
result_url = ""
|
| 75 |
if campaign.get('type')=='url':
|
75 |
if campaign.get('type')=='url':
|
| 76 |
parsed_uri = urlparse(campaign.get('url'))
|
76 |
parsed_uri = urlparse(campaign.get('url'))
|
| Line 173... |
Line 173... |
| 173 |
user_records = cursor.fetchall()
|
173 |
user_records = cursor.fetchall()
|
| 174 |
userids = []
|
174 |
userids = []
|
| 175 |
for record in user_records:
|
175 |
for record in user_records:
|
| 176 |
if str(record[0]) not in userids:
|
176 |
if str(record[0]) not in userids:
|
| 177 |
userids.append(str(record[0]))
|
177 |
userids.append(str(record[0]))
|
| 178 |
campaignUsersMap[str(campaign['_id'])]=userids
|
178 |
campaignUsersMap[long(campaign['_id'])]=userids
|
| 179 |
notificationCampaignsMap[str(campaign['_id'])] = campaign
|
179 |
notificationCampaignsMap[long(campaign['_id'])] = campaign
|
| 180 |
|
180 |
|
| 181 |
def insertPushNotificationEntriesToSent():
|
181 |
def insertPushNotificationEntriesToSent():
|
| 182 |
global userGcmRegIdMap
|
182 |
global userGcmRegIdMap
|
| 183 |
for userList in campaignUsersMap.values():
|
183 |
for userList in campaignUsersMap.values():
|
| 184 |
logging.debug("GCM_REG_SQL_1:- "+GCM_REG_ID_SQL1%(",".join(map(str,userList))))
|
184 |
logging.debug("GCM_REG_SQL_1:- "+GCM_REG_ID_SQL1%(",".join(map(str,userList))))
|
| Line 265... |
Line 265... |
| 265 |
for gcm_id, details in gcmRegIdMap.items():
|
265 |
for gcm_id, details in gcmRegIdMap.items():
|
| 266 |
android_id = None
|
266 |
android_id = None
|
| 267 |
logging.debug("User Id:- "+str(userId)+" ..User Details:- "+str(details))
|
267 |
logging.debug("User Id:- "+str(userId)+" ..User Details:- "+str(details))
|
| 268 |
if details.has_key('android_id'):
|
268 |
if details.has_key('android_id'):
|
| 269 |
android_id = details['android_id']
|
269 |
android_id = details['android_id']
|
| 270 |
pushNotificationObj = __PushNotification(str(campaignId), long(userId), None, 'pending', \
|
270 |
pushNotificationObj = __PushNotification(long(campaignId), long(userId), None, 'pending', \
|
| 271 |
None, None, android_id, "php", None, None, None, None, gcm_id, to_java_date(datetime.now()),0,0)
|
271 |
None, None, android_id, "php", None, None, None, None, gcm_id, to_java_date(datetime.now()),0,0)
|
| 272 |
get_mongo_connection(host=mongoHost).User.pushnotifications.insert(pushNotificationObj.__dict__)
|
272 |
get_mongo_connection(host=mongoHost).User.pushnotifications.insert(pushNotificationObj.__dict__)
|
| 273 |
|
273 |
|
| 274 |
def populatePendingNotificationEntriesToBeSent():
|
274 |
def populatePendingNotificationEntriesToBeSent():
|
| 275 |
global pendingNotificationEntryMap
|
275 |
global pendingNotificationEntryMap
|