| Line 159... |
Line 159... |
| 159 |
select date(o.created) as dateid,sum(quantity) as bquantity,sum(price)
|
159 |
select date(o.created) as dateid,sum(quantity) as bquantity,sum(price)
|
| 160 |
from flipkartorders o JOIN users u ON u.id = ifnull(o.user_id,139) WHERE (LOWER(u.referrer) NOT LIKE
|
160 |
from flipkartorders o JOIN users u ON u.id = ifnull(o.user_id,139) WHERE (LOWER(u.referrer) NOT LIKE
|
| 161 |
'emp%%' OR u.utm_campaign is not NULL) AND u.activated =1 AND date(o.created) >= %s
|
161 |
'emp%%' OR u.utm_campaign is not NULL) AND u.activated =1 AND date(o.created) >= %s
|
| 162 |
GROUP BY date(o.created)) a group by dateid;
|
162 |
GROUP BY date(o.created)) a group by dateid;
|
| 163 |
"""
|
163 |
"""
|
| - |
|
164 |
DOWNO_QUERY="""
|
| - |
|
165 |
SELECT date(created_on),count(distinct merchant_order_id) FROM allorder o
|
| - |
|
166 |
JOIN users u ON u.id = o.user_id WHERE (LOWER(u.referrer) NOT LIKE 'emp%%' OR
|
| - |
|
167 |
u.utm_campaign is not NULL) AND u.activated =1 AND date(o.created_on) >=%s and store_id='spice'
|
| - |
|
168 |
GROUP BY date(o.created_on)
|
| - |
|
169 |
order by date(o.created_on);
|
| - |
|
170 |
"""
|
| 164 |
DOWN_QUERY="""
|
171 |
DOWN_QUERY="""
|
| 165 |
SELECT date(created_on),sum(quantity),sum(amount_paid) FROM allorder o
|
172 |
SELECT date(created_on),sum(quantity),sum(amount_paid) FROM allorder o
|
| 166 |
JOIN users u ON u.id = o.user_id WHERE (LOWER(u.referrer) NOT LIKE
|
173 |
JOIN users u ON u.id = o.user_id WHERE (LOWER(u.referrer) NOT LIKE
|
| 167 |
'emp%%' OR u.utm_campaign is not NULL) AND u.activated =1
|
174 |
'emp%%' OR u.utm_campaign is not NULL) AND u.activated =1
|
| 168 |
AND date(o.created_on) >= %s and store_id='spice' GROUP BY date(o.created_on);
|
175 |
AND date(o.created_on) >= %s and store_id='spice' GROUP BY date(o.created_on);
|
| Line 172... |
Line 179... |
| 172 |
select date(created_on),count(distinct user_id) from allorder
|
179 |
select date(created_on),count(distinct user_id) from allorder
|
| 173 |
where (category='Accessories' or category='Accs') and
|
180 |
where (category='Accessories' or category='Accs') and
|
| 174 |
date(created_on)>=%s and store_id='spice' group by date(created_on) order by date(created_on);
|
181 |
date(created_on)>=%s and store_id='spice' group by date(created_on) order by date(created_on);
|
| 175 |
"""
|
182 |
"""
|
| 176 |
|
183 |
|
| - |
|
184 |
DACCSTO_QUERY="""
|
| - |
|
185 |
SELECT date(created_on),count(distinct merchant_order_id) FROM allorder o JOIN
|
| - |
|
186 |
users u ON u.id = o.user_id WHERE (LOWER(u.referrer) NOT LIKE 'emp%%' OR u.utm_campaign is not NULL)
|
| - |
|
187 |
AND u.activated =1 AND date(o.created_on) >=%s and store_id='spice'
|
| - |
|
188 |
and (category='Accs' or category='Accessories') GROUP BY date(o.created_on)
|
| - |
|
189 |
order by date(o.created_on);
|
| - |
|
190 |
"""
|
| - |
|
191 |
|
| 177 |
DACCSO_QUERY="""
|
192 |
DACCSO_QUERY="""
|
| 178 |
select date(created_on),sum(quantity),sum(amount_paid) from allorder
|
193 |
select date(created_on),sum(quantity),sum(amount_paid) from allorder
|
| 179 |
where (category='Accessories' or category='Accs') and date(created_on)>=%s and store_id='spice'
|
194 |
where (category='Accessories' or category='Accs') and date(created_on)>=%s and store_id='spice'
|
| 180 |
group by date(created_on) order by date(created_on);
|
195 |
group by date(created_on) order by date(created_on);
|
| 181 |
"""
|
196 |
"""
|
| Line 251... |
Line 266... |
| 251 |
JOIN users u ON u.id = s.user_id WHERE (LOWER(u.referrer) NOT LIKE 'emp%%' OR u.utm_campaign is not NULL) AND u.activated =1
|
266 |
JOIN users u ON u.id = s.user_id WHERE (LOWER(u.referrer) NOT LIKE 'emp%%' OR u.utm_campaign is not NULL) AND u.activated =1
|
| 252 |
AND date(s.created) BETWEEN %s AND %s
|
267 |
AND date(s.created) BETWEEN %s AND %s
|
| 253 |
GROUP by month(s.created)
|
268 |
GROUP by month(s.created)
|
| 254 |
order by month(s.created);
|
269 |
order by month(s.created);
|
| 255 |
"""
|
270 |
"""
|
| - |
|
271 |
|
| 256 |
MVOL_QUERY="""
|
272 |
MVOL_QUERY="""
|
| 257 |
select sum(quantity), sum(value) from (SELECT month(date(o.created_on)) as monthid,
|
273 |
select sum(quantity), sum(value) from (SELECT month(date(o.created_on)) as monthid,
|
| 258 |
sum(quantity) as quantity,sum(amount_paid) as value FROM allorder o
|
274 |
sum(quantity) as quantity,sum(amount_paid) as value FROM allorder o
|
| 259 |
JOIN users u ON u.id = o.user_id WHERE (LOWER(u.referrer) NOT LIKE 'emp%%' OR u.utm_campaign is not NULL)
|
275 |
JOIN users u ON u.id = o.user_id WHERE (LOWER(u.referrer) NOT LIKE 'emp%%' OR u.utm_campaign is not NULL)
|
| 260 |
AND u.activated =1 AND date(o.created_on) >=%s
|
276 |
AND u.activated =1 AND date(o.created_on) >=%s
|
| Line 262... |
Line 278... |
| 262 |
select month(date(o.created)) as monthid,sum(quantity) as bquantity,sum(price)
|
278 |
select month(date(o.created)) as monthid,sum(quantity) as bquantity,sum(price)
|
| 263 |
from flipkartorders o JOIN users u ON u.id = ifnull(o.user_id,139) WHERE (LOWER(u.referrer) NOT LIKE
|
279 |
from flipkartorders o JOIN users u ON u.id = ifnull(o.user_id,139) WHERE (LOWER(u.referrer) NOT LIKE
|
| 264 |
'emp%%' OR u.utm_campaign is not NULL) AND u.activated =1 AND date(o.created) >= %s
|
280 |
'emp%%' OR u.utm_campaign is not NULL) AND u.activated =1 AND date(o.created) >= %s
|
| 265 |
GROUP BY month(date(o.created))) a group by monthid;
|
281 |
GROUP BY month(date(o.created))) a group by monthid;
|
| 266 |
"""
|
282 |
"""
|
| - |
|
283 |
|
| - |
|
284 |
MOWNO_QUERY="""
|
| - |
|
285 |
SELECT month(created_on),count(distinct merchant_order_id) FROM allorder o
|
| - |
|
286 |
JOIN users u ON u.id = o.user_id WHERE (LOWER(u.referrer) NOT LIKE 'emp%%' OR
|
| - |
|
287 |
u.utm_campaign is not NULL) AND u.activated =1 AND date(o.created_on) >=%s and store_id='spice'
|
| - |
|
288 |
GROUP BY month(o.created_on)
|
| - |
|
289 |
order by month(o.created_on);
|
| - |
|
290 |
"""
|
| - |
|
291 |
|
| 267 |
MOWN_QUERY="""
|
292 |
MOWN_QUERY="""
|
| 268 |
SELECT sum(quantity),sum(amount_paid) FROM allorder o
|
293 |
SELECT sum(quantity),sum(amount_paid) FROM allorder o
|
| 269 |
JOIN users u ON u.id = o.user_id WHERE (LOWER(u.referrer) NOT LIKE
|
294 |
JOIN users u ON u.id = o.user_id WHERE (LOWER(u.referrer) NOT LIKE
|
| 270 |
'emp%%' OR u.utm_campaign is not NULL) AND u.activated =1
|
295 |
'emp%%' OR u.utm_campaign is not NULL) AND u.activated =1
|
| 271 |
AND date(o.created_on) >= %s and store_id='spice' GROUP BY month(date(o.created_on));
|
296 |
AND date(o.created_on) >= %s and store_id='spice' GROUP BY month(date(o.created_on));
|
| Line 274... |
Line 299... |
| 274 |
select month(created_on),count(distinct user_id) from allorder
|
299 |
select month(created_on),count(distinct user_id) from allorder
|
| 275 |
where (category='Accessories' or category='Accs') and
|
300 |
where (category='Accessories' or category='Accs') and
|
| 276 |
date(created_on)>=%s and store_id='spice' group by month(created_on) order by month(created_on);
|
301 |
date(created_on)>=%s and store_id='spice' group by month(created_on) order by month(created_on);
|
| 277 |
"""
|
302 |
"""
|
| 278 |
|
303 |
|
| - |
|
304 |
MACCSTO_QUERY="""
|
| - |
|
305 |
SELECT month(created_on),count(distinct merchant_order_id) FROM allorder o JOIN
|
| - |
|
306 |
users u ON u.id = o.user_id WHERE (LOWER(u.referrer) NOT LIKE 'emp%%' OR u.utm_campaign is not NULL)
|
| - |
|
307 |
AND u.activated =1 AND date(o.created_on) >=%s and store_id='spice'
|
| - |
|
308 |
and (category='Accs' or category='Accessories') GROUP BY month(o.created_on)
|
| - |
|
309 |
order by month(o.created_on);
|
| - |
|
310 |
"""
|
| - |
|
311 |
|
| 279 |
MACCSO_QUERY="""
|
312 |
MACCSO_QUERY="""
|
| 280 |
select month(created_on),sum(quantity),sum(amount_paid) from allorder
|
313 |
select month(created_on),sum(quantity),sum(amount_paid) from allorder
|
| 281 |
where (category='Accessories' or category='Accs') and date(created_on)>=%s and store_id='spice'
|
314 |
where (category='Accessories' or category='Accs') and date(created_on)>=%s and store_id='spice'
|
| 282 |
group by month(created_on) order by month(created_on);
|
315 |
group by month(created_on) order by month(created_on);
|
| 283 |
"""
|
316 |
"""
|
| Line 351... |
Line 384... |
| 351 |
AND u.activated =1 AND date(o.created_on) >= %s
|
384 |
AND u.activated =1 AND date(o.created_on) >= %s
|
| 352 |
GROUP BY WEEK(date(o.created_on)) UNION
|
385 |
GROUP BY WEEK(date(o.created_on)) UNION
|
| 353 |
select WEEK(date(o.created)) as weekid,sum(quantity) as bquantity,sum(price)
|
386 |
select WEEK(date(o.created)) as weekid,sum(quantity) as bquantity,sum(price)
|
| 354 |
from flipkartorders o JOIN users u ON u.id = ifnull(o.user_id,139)
|
387 |
from flipkartorders o JOIN users u ON u.id = ifnull(o.user_id,139)
|
| 355 |
WHERE (LOWER(u.referrer) NOT LIKE 'emp%%' OR u.utm_campaign is not NULL) AND
|
388 |
WHERE (LOWER(u.referrer) NOT LIKE 'emp%%' OR u.utm_campaign is not NULL) AND
|
| 356 |
u.activated =1 AND date(o.created) >= %s GROUP BY WEEK(date(o.created))) a group by weekid;"""
|
389 |
u.activated =1 AND date(o.created) >= %s GROUP BY WEEK(date(o.created))) a group by weekid;"""
|
| - |
|
390 |
|
| - |
|
391 |
WOWNO_QUERY="""
|
| - |
|
392 |
SELECT week(created_on),count(distinct merchant_order_id) FROM allorder o
|
| - |
|
393 |
JOIN users u ON u.id = o.user_id WHERE (LOWER(u.referrer) NOT LIKE 'emp%%' OR
|
| - |
|
394 |
u.utm_campaign is not NULL) AND u.activated =1 AND date(o.created_on) >=%s and store_id='spice'
|
| - |
|
395 |
GROUP BY week(o.created_on)
|
| - |
|
396 |
order by week(o.created_on);
|
| - |
|
397 |
"""
|
| - |
|
398 |
|
| 357 |
WOWN_QUERY="""
|
399 |
WOWN_QUERY="""
|
| 358 |
SELECT sum(quantity),sum(amount_paid) FROM allorder o
|
400 |
SELECT sum(quantity),sum(amount_paid) FROM allorder o
|
| 359 |
JOIN users u ON u.id = o.user_id WHERE (LOWER(u.referrer) NOT LIKE
|
401 |
JOIN users u ON u.id = o.user_id WHERE (LOWER(u.referrer) NOT LIKE
|
| 360 |
'emp%%' OR u.utm_campaign is not NULL) AND u.activated =1
|
402 |
'emp%%' OR u.utm_campaign is not NULL) AND u.activated =1
|
| 361 |
AND date(o.created_on) >= %s and store_id='spice' GROUP BY WEEK(date(o.created_on));
|
403 |
AND date(o.created_on) >= %s and store_id='spice' GROUP BY WEEK(date(o.created_on));
|
| 362 |
"""
|
404 |
"""
|
| - |
|
405 |
|
| 363 |
WACCSB_QUERY="""
|
406 |
WACCSB_QUERY="""
|
| 364 |
select WEEK(created_on) AS week, count(distinct user_id) from allorder
|
407 |
select WEEK(created_on) AS week, count(distinct user_id) from allorder
|
| 365 |
where (category='Accessories' or category='Accs')
|
408 |
where (category='Accessories' or category='Accs')
|
| 366 |
and date(created_on)>=%s and store_id='spice'
|
409 |
and date(created_on)>=%s and store_id='spice'
|
| 367 |
group by week(created_on)
|
410 |
group by week(created_on)
|
| 368 |
order by WEEK(created_on);
|
411 |
order by WEEK(created_on);
|
| 369 |
"""
|
412 |
"""
|
| - |
|
413 |
|
| - |
|
414 |
WACCSTO_QUERY="""
|
| - |
|
415 |
SELECT week(created_on),count(distinct merchant_order_id) FROM allorder o JOIN
|
| - |
|
416 |
users u ON u.id = o.user_id WHERE (LOWER(u.referrer) NOT LIKE 'emp%%' OR u.utm_campaign is not NULL)
|
| - |
|
417 |
AND u.activated =1 AND date(o.created_on) >=%s and store_id='spice'
|
| - |
|
418 |
and (category='Accs' or category='Accessories') GROUP BY week(o.created_on)
|
| - |
|
419 |
order by week(o.created_on);
|
| - |
|
420 |
"""
|
| - |
|
421 |
|
| 370 |
WACCSO_QUERY="""
|
422 |
WACCSO_QUERY="""
|
| 371 |
select WEEK(created_on),sum(quantity),sum(amount_paid) from allorder
|
423 |
select WEEK(created_on),sum(quantity),sum(amount_paid) from allorder
|
| 372 |
where (category='Accessories' or category='Accs') and date(created_on)>=%s and store_id='spice'
|
424 |
where (category='Accessories' or category='Accs') and date(created_on)>=%s and store_id='spice'
|
| 373 |
group by WEEK(created_on)
|
425 |
group by WEEK(created_on)
|
| 374 |
order by WEEK(created_on);
|
426 |
order by WEEK(created_on);
|
| Line 417... |
Line 469... |
| 417 |
dtoSql = DTO_QUERY
|
469 |
dtoSql = DTO_QUERY
|
| 418 |
dvolSql=DVOL_QUERY
|
470 |
dvolSql=DVOL_QUERY
|
| 419 |
downvolSql=DOWN_QUERY
|
471 |
downvolSql=DOWN_QUERY
|
| 420 |
daccsbSql=DACCSB_QUERY
|
472 |
daccsbSql=DACCSB_QUERY
|
| 421 |
daccsoSql = DACCSO_QUERY
|
473 |
daccsoSql = DACCSO_QUERY
|
| - |
|
474 |
downoSql=DOWNO_QUERY
|
| - |
|
475 |
daccstoSql=DACCSTO_QUERY
|
| 422 |
conn = getDbConnection()
|
476 |
conn = getDbConnection()
|
| 423 |
|
477 |
|
| 424 |
cursor = conn.cursor()
|
478 |
cursor = conn.cursor()
|
| 425 |
cursor.execute(datesql,(cutOffDate,todaysDate()))
|
479 |
cursor.execute(datesql,(cutOffDate,todaysDate()))
|
| 426 |
result = cursor.fetchall()
|
480 |
result = cursor.fetchall()
|
| Line 441... |
Line 495... |
| 441 |
worksheet.write(row, 3, 'DAU', boldStyle)
|
495 |
worksheet.write(row, 3, 'DAU', boldStyle)
|
| 442 |
worksheet.write(row, 4, 'DAB', boldStyle)
|
496 |
worksheet.write(row, 4, 'DAB', boldStyle)
|
| 443 |
worksheet.write(row, 5, 'DTO', boldStyle)
|
497 |
worksheet.write(row, 5, 'DTO', boldStyle)
|
| 444 |
worksheet.write(row, 6, 'DVOL', boldStyle)
|
498 |
worksheet.write(row, 6, 'DVOL', boldStyle)
|
| 445 |
worksheet.write(row, 7, 'DTV', boldStyle)
|
499 |
worksheet.write(row, 7, 'DTV', boldStyle)
|
| - |
|
500 |
worksheet.write(row, 8, 'DOWNORD', boldStyle)
|
| 446 |
worksheet.write(row, 8, 'DOWNVOL', boldStyle)
|
501 |
worksheet.write(row, 9, 'DOWNVOL', boldStyle)
|
| 447 |
worksheet.write(row, 9, 'DOWNVAL', boldStyle)
|
502 |
worksheet.write(row, 10, 'DOWNVAL', boldStyle)
|
| 448 |
worksheet.write(row, 10, 'DACCSU', boldStyle)
|
503 |
worksheet.write(row, 11, 'DACCSU', boldStyle)
|
| 449 |
worksheet.write(row, 11, 'DACCSB', boldStyle)
|
504 |
worksheet.write(row, 12, 'DACCSB', boldStyle)
|
| - |
|
505 |
worksheet.write(row, 13, 'DACCSORD', boldStyle)
|
| 450 |
worksheet.write(row, 12, 'DACCSOVOL', boldStyle)
|
506 |
worksheet.write(row, 14, 'DACCSOVOL', boldStyle)
|
| 451 |
worksheet.write(row, 13, 'DACCSOVAL', boldStyle)
|
507 |
worksheet.write(row, 15, 'DACCSOVAL', boldStyle)
|
| 452 |
dateMap={}
|
508 |
dateMap={}
|
| 453 |
for r in result:
|
509 |
for r in result:
|
| 454 |
row += 1
|
510 |
row += 1
|
| 455 |
column = 0
|
511 |
column = 0
|
| 456 |
for data in r :
|
512 |
for data in r :
|
| Line 526... |
Line 582... |
| 526 |
for data in r :
|
582 |
for data in r :
|
| 527 |
worksheet.write(row, column, int(data) if type(data) is float else data, date_format if type(data) is date else default_format)
|
583 |
worksheet.write(row, column, int(data) if type(data) is float else data, date_format if type(data) is date else default_format)
|
| 528 |
column += 1
|
584 |
column += 1
|
| 529 |
|
585 |
|
| 530 |
row = 0
|
586 |
row = 0
|
| 531 |
cursor.execute(downvolSql,(cutOffDate))
|
587 |
cursor.execute(downoSql,(cutOffDate))
|
| 532 |
result = cursor.fetchall()
|
588 |
result = cursor.fetchall()
|
| 533 |
|
589 |
|
| 534 |
for r in result:
|
590 |
for r in result:
|
| 535 |
column = 8
|
591 |
column = 8
|
| 536 |
row=dateMap.get(str(r[0]))
|
592 |
row=dateMap.get(str(r[0]))
|
| 537 |
if row:
|
593 |
if row:
|
| 538 |
worksheet.write(row, column, r[1])
|
594 |
worksheet.write(row, column, r[1])
|
| - |
|
595 |
|
| - |
|
596 |
row = 0
|
| - |
|
597 |
cursor.execute(downvolSql,(cutOffDate))
|
| - |
|
598 |
result = cursor.fetchall()
|
| - |
|
599 |
|
| - |
|
600 |
for r in result:
|
| - |
|
601 |
column = 9
|
| - |
|
602 |
row=dateMap.get(str(r[0]))
|
| - |
|
603 |
if row:
|
| - |
|
604 |
worksheet.write(row, column, r[1])
|
| 539 |
column += 1
|
605 |
column += 1
|
| 540 |
worksheet.write(row, column, r[2])
|
606 |
worksheet.write(row, column, r[2])
|
| 541 |
|
607 |
|
| 542 |
row = 1
|
608 |
row = 1
|
| 543 |
column=10
|
609 |
column=11
|
| 544 |
breakDate = to_java_date(datetime.now())
|
610 |
breakDate = to_java_date(datetime.now())
|
| 545 |
currentDay = cutOff*1000
|
611 |
currentDay = cutOff*1000
|
| 546 |
while True:
|
612 |
while True:
|
| 547 |
currentDay = currentDay + 86400000
|
613 |
currentDay = currentDay + 86400000
|
| 548 |
result = get_mongo_connection_new().User.browsinghistories.find({"$and":[{'created':{"$gte":currentDay-86400000}},{'created':{"$lte":currentDay}},{"url":{"$regex" : "http://api.profittill.com/category/6"}}]}).distinct('user_id')
|
614 |
result = get_mongo_connection_new().User.browsinghistories.find({"$and":[{'created':{"$gte":currentDay-86400000}},{'created':{"$lte":currentDay}},{"url":{"$regex" : "http://api.profittill.com/category/6"}}]}).distinct('user_id')
|
| Line 553... |
Line 619... |
| 553 |
|
619 |
|
| 554 |
row = 0
|
620 |
row = 0
|
| 555 |
cursor.execute(daccsbSql,(cutOffDate))
|
621 |
cursor.execute(daccsbSql,(cutOffDate))
|
| 556 |
result = cursor.fetchall()
|
622 |
result = cursor.fetchall()
|
| 557 |
for r in result:
|
623 |
for r in result:
|
| 558 |
column = 11
|
624 |
column = 12
|
| 559 |
row=dateMap.get(str(r[0]))
|
625 |
row=dateMap.get(str(r[0]))
|
| 560 |
if row:
|
626 |
if row:
|
| 561 |
worksheet.write(row, column, r[1])
|
627 |
worksheet.write(row, column, r[1])
|
| 562 |
|
628 |
|
| 563 |
row = 0
|
629 |
row = 0
|
| - |
|
630 |
cursor.execute(daccstoSql,(cutOffDate))
|
| - |
|
631 |
result = cursor.fetchall()
|
| - |
|
632 |
|
| - |
|
633 |
for r in result:
|
| - |
|
634 |
column = 13
|
| - |
|
635 |
row=dateMap.get(str(r[0]))
|
| - |
|
636 |
if row:
|
| - |
|
637 |
worksheet.write(row, column, r[1])
|
| - |
|
638 |
|
| - |
|
639 |
row = 0
|
| 564 |
cursor.execute(daccsoSql,(cutOffDate))
|
640 |
cursor.execute(daccsoSql,(cutOffDate))
|
| 565 |
result = cursor.fetchall()
|
641 |
result = cursor.fetchall()
|
| 566 |
|
642 |
|
| 567 |
for r in result:
|
643 |
for r in result:
|
| 568 |
column = 12
|
644 |
column = 14
|
| 569 |
row=dateMap.get(str(r[0]))
|
645 |
row=dateMap.get(str(r[0]))
|
| 570 |
if row:
|
646 |
if row:
|
| 571 |
worksheet.write(row, column, r[1])
|
647 |
worksheet.write(row, column, r[1])
|
| 572 |
column += 1
|
648 |
column += 1
|
| 573 |
worksheet.write(row, column, r[2])
|
649 |
worksheet.write(row, column, r[2])
|
| Line 579... |
Line 655... |
| 579 |
mabSql = MAB_QUERY
|
655 |
mabSql = MAB_QUERY
|
| 580 |
mtoSql = MTO_QUERY
|
656 |
mtoSql = MTO_QUERY
|
| 581 |
mvolSql=MVOL_QUERY
|
657 |
mvolSql=MVOL_QUERY
|
| 582 |
mownvolSql=MOWN_QUERY
|
658 |
mownvolSql=MOWN_QUERY
|
| 583 |
maccsbSql= MACCSB_QUERY
|
659 |
maccsbSql= MACCSB_QUERY
|
| - |
|
660 |
maccsoSql= MACCSO_QUERY
|
| - |
|
661 |
mownoSql= MOWNO_QUERY
|
| 584 |
maccsoSql= MACCSO_QUERY
|
662 |
maccstoSql= MACCSTO_QUERY
|
| 585 |
|
663 |
|
| 586 |
conn = getDbConnection()
|
664 |
conn = getDbConnection()
|
| 587 |
|
665 |
|
| 588 |
cursor = conn.cursor()
|
666 |
cursor = conn.cursor()
|
| 589 |
|
667 |
|
| Line 604... |
Line 682... |
| 604 |
worksheet.write(row, 3, 'MAU', boldStyle)
|
682 |
worksheet.write(row, 3, 'MAU', boldStyle)
|
| 605 |
worksheet.write(row, 4, 'MAB', boldStyle)
|
683 |
worksheet.write(row, 4, 'MAB', boldStyle)
|
| 606 |
worksheet.write(row, 5, 'MTO', boldStyle)
|
684 |
worksheet.write(row, 5, 'MTO', boldStyle)
|
| 607 |
worksheet.write(row, 6, 'MVOL', boldStyle)
|
685 |
worksheet.write(row, 6, 'MVOL', boldStyle)
|
| 608 |
worksheet.write(row, 7, 'MTV', boldStyle)
|
686 |
worksheet.write(row, 7, 'MTV', boldStyle)
|
| - |
|
687 |
worksheet.write(row, 8, 'MOWNORD', boldStyle)
|
| 609 |
worksheet.write(row, 8, 'MOWNVOL', boldStyle)
|
688 |
worksheet.write(row, 9, 'MOWNVOL', boldStyle)
|
| 610 |
worksheet.write(row, 9, 'MOWNVAL', boldStyle)
|
689 |
worksheet.write(row, 10, 'MOWNVAL', boldStyle)
|
| 611 |
worksheet.write(row, 10, 'MACCSU', boldStyle)
|
690 |
worksheet.write(row, 11, 'MACCSU', boldStyle)
|
| 612 |
worksheet.write(row, 11, 'MACCSB', boldStyle)
|
691 |
worksheet.write(row, 12, 'MACCSB', boldStyle)
|
| - |
|
692 |
worksheet.write(row, 13, 'MACCSORD', boldStyle)
|
| 613 |
worksheet.write(row, 12, 'MACCSOVOL', boldStyle)
|
693 |
worksheet.write(row, 14, 'MACCSOVOL', boldStyle)
|
| 614 |
worksheet.write(row, 13, 'MACCSOVAL', boldStyle)
|
694 |
worksheet.write(row, 15, 'MACCSOVAL', boldStyle)
|
| 615 |
|
695 |
|
| 616 |
monthMapDb = {}
|
696 |
monthMapDb = {}
|
| 617 |
for r in result:
|
697 |
for r in result:
|
| 618 |
row += 1
|
698 |
row += 1
|
| 619 |
column = 0
|
699 |
column = 0
|
| Line 689... |
Line 769... |
| 689 |
row += 1
|
769 |
row += 1
|
| 690 |
column = 6
|
770 |
column = 6
|
| 691 |
for data in r :
|
771 |
for data in r :
|
| 692 |
worksheet.write(row, column, int(data) if type(data) is float else data, date_format if type(data) is date else default_format)
|
772 |
worksheet.write(row, column, int(data) if type(data) is float else data, date_format if type(data) is date else default_format)
|
| 693 |
column += 1
|
773 |
column += 1
|
| - |
|
774 |
|
| - |
|
775 |
row = 0
|
| - |
|
776 |
cursor.execute(mownoSql,(cutOffDate))
|
| - |
|
777 |
result = cursor.fetchall()
|
| - |
|
778 |
for r in result:
|
| - |
|
779 |
column = 8
|
| - |
|
780 |
row=monthMapDb.get(str(r[0]))
|
| - |
|
781 |
if row:
|
| - |
|
782 |
worksheet.write(row, column, r[1])
|
| 694 |
|
783 |
|
| 695 |
row = 0
|
784 |
row = 0
|
| 696 |
cursor.execute(mownvolSql,(cutOffDate))
|
785 |
cursor.execute(mownvolSql,(cutOffDate))
|
| 697 |
result = cursor.fetchall()
|
786 |
result = cursor.fetchall()
|
| 698 |
|
787 |
|
| 699 |
for r in result:
|
788 |
for r in result:
|
| 700 |
row += 1
|
789 |
row += 1
|
| 701 |
column = 8
|
790 |
column = 9
|
| 702 |
for data in r :
|
791 |
for data in r :
|
| 703 |
worksheet.write(row, column, int(data) if type(data) is float else data, date_format if type(data) is date else default_format)
|
792 |
worksheet.write(row, column, int(data) if type(data) is float else data, date_format if type(data) is date else default_format)
|
| 704 |
column += 1
|
793 |
column += 1
|
| 705 |
|
794 |
|
| 706 |
row=1
|
795 |
row=1
|
| 707 |
column=10
|
796 |
column=11
|
| 708 |
breakDate = to_java_date(datetime.now())
|
797 |
breakDate = to_java_date(datetime.now())
|
| 709 |
currentDay = cutOff*1000
|
798 |
currentDay = cutOff*1000
|
| 710 |
while True:
|
799 |
while True:
|
| 711 |
currentDay = currentDay + (monthMap.get(month_get(currentDay))*86400000)
|
800 |
currentDay = currentDay + (monthMap.get(month_get(currentDay))*86400000)
|
| 712 |
result = get_mongo_connection_new().User.browsinghistories.find({"$and":[{'created':{"$gte":currentDay- (monthMap.get(month_get(currentDay))*86400000)}},{'created':{"$lte":currentDay}},{"url":{"$regex" : "http://api.profittill.com/category/6"}}]}).distinct('user_id')
|
801 |
result = get_mongo_connection_new().User.browsinghistories.find({"$and":[{'created':{"$gte":currentDay- (monthMap.get(month_get(currentDay))*86400000)}},{'created':{"$lte":currentDay}},{"url":{"$regex" : "http://api.profittill.com/category/6"}}]}).distinct('user_id')
|
| Line 719... |
Line 808... |
| 719 |
|
808 |
|
| 720 |
row = 0
|
809 |
row = 0
|
| 721 |
cursor.execute(maccsbSql,(cutOffDate))
|
810 |
cursor.execute(maccsbSql,(cutOffDate))
|
| 722 |
result = cursor.fetchall()
|
811 |
result = cursor.fetchall()
|
| 723 |
for r in result:
|
812 |
for r in result:
|
| 724 |
column = 11
|
813 |
column = 12
|
| - |
|
814 |
row=monthMapDb.get(str(r[0]))
|
| - |
|
815 |
if row:
|
| - |
|
816 |
worksheet.write(row, column, r[1])
|
| - |
|
817 |
|
| - |
|
818 |
row = 0
|
| - |
|
819 |
cursor.execute(maccstoSql,(cutOffDate))
|
| - |
|
820 |
result = cursor.fetchall()
|
| - |
|
821 |
|
| - |
|
822 |
for r in result:
|
| - |
|
823 |
column = 13
|
| 725 |
row=monthMapDb.get(str(r[0]))
|
824 |
row=monthMapDb.get(str(r[0]))
|
| 726 |
if row:
|
825 |
if row:
|
| 727 |
worksheet.write(row, column, r[1])
|
826 |
worksheet.write(row, column, r[1])
|
| 728 |
|
827 |
|
| 729 |
row = 0
|
828 |
row = 0
|
| 730 |
cursor.execute(maccsoSql,(cutOffDate))
|
829 |
cursor.execute(maccsoSql,(cutOffDate))
|
| 731 |
result = cursor.fetchall()
|
830 |
result = cursor.fetchall()
|
| 732 |
|
831 |
|
| 733 |
for r in result:
|
832 |
for r in result:
|
| 734 |
column = 12
|
833 |
column = 14
|
| 735 |
row=monthMapDb.get(str(r[0]))
|
834 |
row=monthMapDb.get(str(r[0]))
|
| 736 |
if row:
|
835 |
if row:
|
| 737 |
worksheet.write(row, column, r[1])
|
836 |
worksheet.write(row, column, r[1])
|
| 738 |
column += 1
|
837 |
column += 1
|
| 739 |
worksheet.write(row, column, r[2])
|
838 |
worksheet.write(row, column, r[2])
|
| Line 748... |
Line 847... |
| 748 |
wtoSql = WTO_QUERY
|
847 |
wtoSql = WTO_QUERY
|
| 749 |
wownSql=WOWN_QUERY
|
848 |
wownSql=WOWN_QUERY
|
| 750 |
wvolSql=WVOL_QUERY
|
849 |
wvolSql=WVOL_QUERY
|
| 751 |
waccsbSql = WACCSB_QUERY
|
850 |
waccsbSql = WACCSB_QUERY
|
| 752 |
waccsoSql = WACCSO_QUERY
|
851 |
waccsoSql = WACCSO_QUERY
|
| - |
|
852 |
wownoSql=WOWNO_QUERY
|
| - |
|
853 |
waccstoSql=WACCSTO_QUERY
|
| - |
|
854 |
|
| 753 |
conn = getDbConnection()
|
855 |
conn = getDbConnection()
|
| 754 |
|
856 |
|
| 755 |
cursor = conn.cursor()
|
857 |
cursor = conn.cursor()
|
| 756 |
|
858 |
|
| 757 |
cursor.execute(weekSql,(last_day(cutOffDate, 'sunday')))
|
859 |
cursor.execute(weekSql,(last_day(cutOffDate, 'sunday')))
|
| Line 771... |
Line 873... |
| 771 |
worksheet.write(row, 3, 'WAU', boldStyle)
|
873 |
worksheet.write(row, 3, 'WAU', boldStyle)
|
| 772 |
worksheet.write(row, 4, 'WAB', boldStyle)
|
874 |
worksheet.write(row, 4, 'WAB', boldStyle)
|
| 773 |
worksheet.write(row, 5, 'WTO', boldStyle)
|
875 |
worksheet.write(row, 5, 'WTO', boldStyle)
|
| 774 |
worksheet.write(row, 6, 'WVOL', boldStyle)
|
876 |
worksheet.write(row, 6, 'WVOL', boldStyle)
|
| 775 |
worksheet.write(row, 7, 'WTV', boldStyle)
|
877 |
worksheet.write(row, 7, 'WTV', boldStyle)
|
| - |
|
878 |
worksheet.write(row, 8, 'WOWNORD', boldStyle)
|
| 776 |
worksheet.write(row, 8, 'WOWNVOL', boldStyle)
|
879 |
worksheet.write(row, 9, 'WOWNVOL', boldStyle)
|
| 777 |
worksheet.write(row, 9, 'WOWNVAL', boldStyle)
|
880 |
worksheet.write(row, 10, 'WOWNVAL', boldStyle)
|
| 778 |
worksheet.write(row, 10, 'WACCSU', boldStyle)
|
881 |
worksheet.write(row, 11, 'WACCSU', boldStyle)
|
| 779 |
worksheet.write(row, 11, 'WACCSB', boldStyle)
|
882 |
worksheet.write(row, 12, 'WACCSB', boldStyle)
|
| - |
|
883 |
worksheet.write(row, 13, 'WACCSORD', boldStyle)
|
| 780 |
worksheet.write(row, 12, 'WACCSVOL', boldStyle)
|
884 |
worksheet.write(row, 14, 'WACCSVOL', boldStyle)
|
| 781 |
worksheet.write(row, 13, 'WACCSVAL', boldStyle)
|
885 |
worksheet.write(row, 15, 'WACCSVAL', boldStyle)
|
| - |
|
886 |
|
| 782 |
weekMap={}
|
887 |
weekMap={}
|
| - |
|
888 |
|
| 783 |
for r in result:
|
889 |
for r in result:
|
| 784 |
row += 1
|
890 |
row += 1
|
| 785 |
column = 0
|
891 |
column = 0
|
| 786 |
worksheet.write(row, column, int(r[0]) if type(r[0]) is float else r[0], date_format if type(r[0]) is date else default_format)
|
892 |
worksheet.write(row, column, int(r[0]) if type(r[0]) is float else r[0], date_format if type(r[0]) is date else default_format)
|
| 787 |
weekMap[str(r[1])]=row
|
893 |
weekMap[str(r[1])]=row
|
| Line 854... |
Line 960... |
| 854 |
row += 1
|
960 |
row += 1
|
| 855 |
column = 6
|
961 |
column = 6
|
| 856 |
for data in r :
|
962 |
for data in r :
|
| 857 |
worksheet.write(row, column, int(data) if type(data) is float else data, date_format if type(data) is date else default_format)
|
963 |
worksheet.write(row, column, int(data) if type(data) is float else data, date_format if type(data) is date else default_format)
|
| 858 |
column += 1
|
964 |
column += 1
|
| - |
|
965 |
|
| - |
|
966 |
row = 0
|
| - |
|
967 |
cursor.execute(wownoSql,(cutOffDate))
|
| - |
|
968 |
result = cursor.fetchall()
|
| - |
|
969 |
for r in result:
|
| - |
|
970 |
column = 8
|
| - |
|
971 |
row=weekMap.get(str(r[0]))
|
| - |
|
972 |
if row:
|
| - |
|
973 |
worksheet.write(row, column, r[1])
|
| 859 |
|
974 |
|
| 860 |
row = 0
|
975 |
row = 0
|
| 861 |
cursor.execute(wownSql,(cutOffDate))
|
976 |
cursor.execute(wownSql,(cutOffDate))
|
| 862 |
result = cursor.fetchall()
|
977 |
result = cursor.fetchall()
|
| 863 |
|
978 |
|
| 864 |
for r in result:
|
979 |
for r in result:
|
| 865 |
row += 1
|
980 |
row += 1
|
| 866 |
column = 8
|
981 |
column = 9
|
| 867 |
for data in r :
|
982 |
for data in r :
|
| 868 |
worksheet.write(row, column, int(data) if type(data) is float else data, date_format if type(data) is date else default_format)
|
983 |
worksheet.write(row, column, int(data) if type(data) is float else data, date_format if type(data) is date else default_format)
|
| 869 |
column += 1
|
984 |
column += 1
|
| 870 |
|
985 |
|
| 871 |
row=1
|
986 |
row=1
|
| 872 |
column=10
|
987 |
column=11
|
| 873 |
breakDate = to_java_date(datetime.now())
|
988 |
breakDate = to_java_date(datetime.now())
|
| 874 |
currentDay = to_java_date(last_day(cutOffDate, 'sunday'))
|
989 |
currentDay = to_java_date(last_day(cutOffDate, 'sunday'))
|
| 875 |
while True:
|
990 |
while True:
|
| 876 |
currentDay = currentDay + (7*86400000)
|
991 |
currentDay = currentDay + (7*86400000)
|
| 877 |
result = get_mongo_connection_new().User.browsinghistories.find({"$and":[{'created':{"$gte":currentDay-(6*86400000)}},{'created':{"$lte":currentDay}},{"url":{"$regex" : "http://api.profittill.com/category/6"}}]}).distinct('user_id')
|
992 |
result = get_mongo_connection_new().User.browsinghistories.find({"$and":[{'created':{"$gte":currentDay-(6*86400000)}},{'created':{"$lte":currentDay}},{"url":{"$regex" : "http://api.profittill.com/category/6"}}]}).distinct('user_id')
|
| 878 |
worksheet.write(row,column,len(result))
|
993 |
worksheet.write(row,column,len(result))
|
| 879 |
row=row+1
|
994 |
row=row+1
|
| 880 |
if currentDay>breakDate:
|
995 |
if currentDay>breakDate:
|
| 881 |
break
|
996 |
break
|
| - |
|
997 |
|
| 882 |
row = 0
|
998 |
row = 0
|
| 883 |
cursor.execute(waccsbSql,(cutOffDate))
|
999 |
cursor.execute(waccsbSql,(cutOffDate))
|
| 884 |
result = cursor.fetchall()
|
1000 |
result = cursor.fetchall()
|
| 885 |
for r in result:
|
1001 |
for r in result:
|
| 886 |
column = 11
|
1002 |
column = 12
|
| 887 |
row=weekMap.get(str(r[0]))
|
1003 |
row=weekMap.get(str(r[0]))
|
| 888 |
if row:
|
1004 |
if row:
|
| 889 |
worksheet.write(row, column, r[1])
|
1005 |
worksheet.write(row, column, r[1])
|
| - |
|
1006 |
|
| - |
|
1007 |
row = 0
|
| - |
|
1008 |
cursor.execute(waccstoSql,(cutOffDate))
|
| - |
|
1009 |
result = cursor.fetchall()
|
| - |
|
1010 |
|
| - |
|
1011 |
for r in result:
|
| - |
|
1012 |
column = 13
|
| - |
|
1013 |
row=weekMap.get(str(r[0]))
|
| - |
|
1014 |
if row:
|
| - |
|
1015 |
worksheet.write(row, column, r[1])
|
| 890 |
|
1016 |
|
| 891 |
row = 0
|
1017 |
row = 0
|
| 892 |
cursor.execute(waccsoSql,(cutOffDate))
|
1018 |
cursor.execute(waccsoSql,(cutOffDate))
|
| 893 |
result = cursor.fetchall()
|
1019 |
result = cursor.fetchall()
|
| 894 |
|
1020 |
|
| 895 |
for r in result:
|
1021 |
for r in result:
|
| 896 |
column = 12
|
1022 |
column = 14
|
| 897 |
row=weekMap.get(str(r[0]))
|
1023 |
row=weekMap.get(str(r[0]))
|
| 898 |
if row:
|
1024 |
if row:
|
| 899 |
worksheet.write(row, column, r[1])
|
1025 |
worksheet.write(row, column, r[1])
|
| 900 |
column += 1
|
1026 |
column += 1
|
| 901 |
worksheet.write(row, column, r[2])
|
1027 |
worksheet.write(row, column, r[2])
|