| Line 39... |
Line 39... |
| 39 |
userGcmRegIdMap = {}
|
39 |
userGcmRegIdMap = {}
|
| 40 |
db = MySQLdb.connect('localhost',"root","shop2020","dtr" )
|
40 |
db = MySQLdb.connect('localhost',"root","shop2020","dtr" )
|
| 41 |
cursor = db.cursor()
|
41 |
cursor = db.cursor()
|
| 42 |
|
42 |
|
| 43 |
ALL_STORES_SQL = "select * from stores"
|
43 |
ALL_STORES_SQL = "select * from stores"
|
| 44 |
GCM_REG_ID_SQL1 = "select x.user_id, x.gcm_regid, x.id, x.androidid, x.created from (select * from gcm_users where user_id in %s and androidid is not null order by id desc) as x group by x.user_id, x.gcm_regid, x.androidid"
|
44 |
GCM_REG_ID_SQL1 = "select x.user_id, x.gcm_regid, x.id, x.androidid, x.created from (select * from gcm_users where user_id in (%s) and androidid is not null order by id desc) as x group by x.user_id, x.gcm_regid, x.androidid"
|
| 45 |
GCM_REG_ID_SQL2 = "select x.user_id, x.gcm_regid, x.id, x.androidid, x.created from (select * from gcm_users where user_id in %s and androidid is null order by id desc) as x group by x.user_id, x.gcm_regid"
|
45 |
GCM_REG_ID_SQL2 = "select x.user_id, x.gcm_regid, x.id, x.androidid, x.created from (select * from gcm_users where user_id in (%s) and androidid is null order by id desc) as x group by x.user_id, x.gcm_regid"
|
| 46 |
|
46 |
|
| 47 |
cursor.execute(ALL_STORES_SQL)
|
47 |
cursor.execute(ALL_STORES_SQL)
|
| 48 |
result_stores = cursor.fetchall()
|
48 |
result_stores = cursor.fetchall()
|
| 49 |
domainStoresMap = {}
|
49 |
domainStoresMap = {}
|
| 50 |
for rec in result_stores:
|
50 |
for rec in result_stores:
|
| Line 179... |
Line 179... |
| 179 |
notificationCampaignsMap[str(campaign['_id'])] = campaign
|
179 |
notificationCampaignsMap[str(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%(str(tuple(userList))))
|
184 |
logging.debug("GCM_REG_SQL_1:- "+GCM_REG_ID_SQL1%(",".join(map(str,userList))))
|
| 185 |
cursor.execute(GCM_REG_ID_SQL1%(str(tuple(userList))))
|
185 |
cursor.execute(GCM_REG_ID_SQL1%(",".join(map(str,userList))))
|
| 186 |
result_data = cursor.fetchall()
|
186 |
result_data = cursor.fetchall()
|
| 187 |
|
187 |
|
| 188 |
if result_data and len(result_data)>0:
|
188 |
if result_data and len(result_data)>0:
|
| 189 |
user_list = []
|
189 |
user_list = []
|
| 190 |
for userId in userList:
|
190 |
for userId in userList:
|
| Line 211... |
Line 211... |
| 211 |
detailMap['android_id'] = dataRec[3]
|
211 |
detailMap['android_id'] = dataRec[3]
|
| 212 |
gcmRegIdMap[dataRec[2]]= detailMap
|
212 |
gcmRegIdMap[dataRec[2]]= detailMap
|
| 213 |
userGcmRegIdMap[dataRec[0]] = gcmRegIdMap
|
213 |
userGcmRegIdMap[dataRec[0]] = gcmRegIdMap
|
| 214 |
|
214 |
|
| 215 |
logging.debug("Old Users.."+str(user_list))
|
215 |
logging.debug("Old Users.."+str(user_list))
|
| 216 |
if len(user_list)<=1:
|
- |
|
| 217 |
user_list.append('0')
|
- |
|
| 218 |
user_list.append('0')
|
- |
|
| 219 |
logging.debug("GCM_REG_SQL_2:- "+GCM_REG_ID_SQL2%(str(tuple(user_list))))
|
216 |
logging.debug("GCM_REG_SQL_2:- "+GCM_REG_ID_SQL2%(",".join(map(str,user_list))))
|
| 220 |
cursor.execute(GCM_REG_ID_SQL2%(str(tuple(user_list))))
|
217 |
cursor.execute(GCM_REG_ID_SQL2%(",".join(map(str,user_list))))
|
| 221 |
result_data = cursor.fetchall()
|
218 |
result_data = cursor.fetchall()
|
| 222 |
for dataRec in result_data:
|
219 |
for dataRec in result_data:
|
| 223 |
if userGcmRegIdMap.has_key(dataRec[0]):
|
220 |
if userGcmRegIdMap.has_key(dataRec[0]):
|
| 224 |
detailMap = {}
|
221 |
detailMap = {}
|
| 225 |
gcmRegIdMap = userGcmRegIdMap.get(dataRec[0])
|
222 |
gcmRegIdMap = userGcmRegIdMap.get(dataRec[0])
|
| Line 235... |
Line 232... |
| 235 |
if dataRec[3] is not None:
|
232 |
if dataRec[3] is not None:
|
| 236 |
detailMap['android_id'] = dataRec[3]
|
233 |
detailMap['android_id'] = dataRec[3]
|
| 237 |
gcmRegIdMap[dataRec[2]]= detailMap
|
234 |
gcmRegIdMap[dataRec[2]]= detailMap
|
| 238 |
userGcmRegIdMap[dataRec[0]] = gcmRegIdMap
|
235 |
userGcmRegIdMap[dataRec[0]] = gcmRegIdMap
|
| 239 |
else:
|
236 |
else:
|
| 240 |
logging.debug("GCM_REG_SQL_2:- "+GCM_REG_ID_SQL2%(str(tuple(userList))))
|
237 |
logging.debug("GCM_REG_SQL_2:- "+GCM_REG_ID_SQL2%(",".join(map(str,userList))))
|
| 241 |
cursor.execute(GCM_REG_ID_SQL2%(str(tuple(userList))))
|
238 |
cursor.execute(GCM_REG_ID_SQL2%(",".join(map(str,userList))))
|
| 242 |
result_data = cursor.fetchall()
|
239 |
result_data = cursor.fetchall()
|
| 243 |
for dataRec in result_data:
|
240 |
for dataRec in result_data:
|
| 244 |
if userGcmRegIdMap.has_key(dataRec[0]):
|
241 |
if userGcmRegIdMap.has_key(dataRec[0]):
|
| 245 |
detailMap = {}
|
242 |
detailMap = {}
|
| 246 |
gcmRegIdMap = userGcmRegIdMap.get(dataRec[0])
|
243 |
gcmRegIdMap = userGcmRegIdMap.get(dataRec[0])
|