Subversion Repositories SmartDukaan

Rev

Rev 16973 | Rev 17032 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16973 Rev 17031
Line 100... Line 100...
100
 
100
 
101
DNRU_QUERY="""
101
DNRU_QUERY="""
102
SELECT count(*) 
102
SELECT count(*) 
103
FROM users u WHERE 
103
FROM users u WHERE 
104
(LOWER(u.referrer) NOT LIKE  'emp%' OR u.utm_campaign is not NULL) AND u.activated =1
104
(LOWER(u.referrer) NOT LIKE  'emp%' OR u.utm_campaign is not NULL) AND u.activated =1
105
AND date(u.created) > '2015-03-08'
105
AND date(u.activation_time) > '2015-03-08'
106
group by date(u.created) 
106
group by date(u.activation_time) 
107
order by date(u.created)
107
order by date(u.activation_time)
108
"""
108
"""
109
 
109
 
110
DAU_QUERY="""
110
DAU_QUERY="""
111
SELECT count(distinct d.user_id) 
111
SELECT count(distinct d.user_id) 
112
FROM daily_visitors d join users u WHERE u.id=d.user_id 
112
FROM daily_visitors d join users u WHERE u.id=d.user_id 
Line 157... Line 157...
157
#"""
157
#"""
158
 
158
 
159
MNRU_QUERY="""
159
MNRU_QUERY="""
160
SELECT count(*) FROM users u WHERE 
160
SELECT count(*) FROM users u WHERE 
161
(LOWER(u.referrer) NOT LIKE  'emp%' OR u.utm_campaign is not NULL) AND u.activated =1
161
(LOWER(u.referrer) NOT LIKE  'emp%' OR u.utm_campaign is not NULL) AND u.activated =1
162
AND date(u.created) > '2015-03-08' 
162
AND date(u.activation_time) > '2015-03-08' 
163
group by month(u.created)
163
group by month(u.activation_time)
164
order by month(u.created) 
164
order by month(u.activation_time) 
165
"""
165
"""
166
 
166
 
167
MAU_QUERY="""
167
MAU_QUERY="""
168
SELECT count(distinct d.user_id) 
168
SELECT count(distinct d.user_id) 
169
FROM daily_visitors d join users u where u.id=d.user_id AND 
169
FROM daily_visitors d join users u where u.id=d.user_id AND 
Line 216... Line 216...
216
 
216
 
217
WNRU_QUERY="""
217
WNRU_QUERY="""
218
SELECT COUNT(*)
218
SELECT COUNT(*)
219
FROM users u WHERE 
219
FROM users u WHERE 
220
(LOWER(u.referrer) NOT LIKE  'emp%' OR u.utm_campaign is not NULL) AND u.activated =1
220
(LOWER(u.referrer) NOT LIKE  'emp%' OR u.utm_campaign is not NULL) AND u.activated =1
221
AND date(u.created) > '2015-03-08' 
221
AND date(u.activation_time) > '2015-03-08' 
222
GROUP BY WEEK(date(u.created))
222
GROUP BY WEEK(date(u.activation_time))
223
ORDER BY WEEK(date(u.created))
223
ORDER BY WEEK(date(u.activation_time))
224
 
224
 
225
"""
225
"""
226
WAU_QUERY="""
226
WAU_QUERY="""
227
SELECT  COUNT(distinct d.user_id) AS total
227
SELECT  COUNT(distinct d.user_id) AS total
228
FROM  daily_visitors d join users u where u.id=d.user_id AND 
228
FROM  daily_visitors d join users u where u.id=d.user_id AND 
Line 596... Line 596...
596
        column = 9
596
        column = 9
597
        worksheet.write(row,column,monthWiseSaholicOrderMap.get(x).value)
597
        worksheet.write(row,column,monthWiseSaholicOrderMap.get(x).value)
598
        column += 1
598
        column += 1
599
          
599
          
600
    workbook.save(TMP_FILE)
600
    workbook.save(TMP_FILE)
601
    sendmail(["manas.kapoor@shop2020.in","rajneesh.arora@saholic.com"], "", TMP_FILE, SUBJECT)
-
 
602
    #sendmail(["manas.kapoor@shop2020.in"], "", TMP_FILE, SUBJECT)
-
 
603
 
601
    
604
def generateWeeklyReport():
602
def generateWeeklyReport():
605
    weekSql = WEEK_QUERY
603
    weekSql = WEEK_QUERY
606
    wnruSql = WNRU_QUERY
604
    wnruSql = WNRU_QUERY
607
    wauSql = WAU_QUERY
605
    wauSql = WAU_QUERY
608
    wabSql = WAB_QUERY
606
    wabSql = WAB_QUERY
Line 762... Line 760...
762
    fileMsg.set_payload(file(TMP_FILE).read())
760
    fileMsg.set_payload(file(TMP_FILE).read())
763
    encoders.encode_base64(fileMsg)
761
    encoders.encode_base64(fileMsg)
764
    fileMsg.add_header('Content-Disposition', 'attachment;filename=' + fileName)
762
    fileMsg.add_header('Content-Disposition', 'attachment;filename=' + fileName)
765
    msg.attach(fileMsg)
763
    msg.attach(fileMsg)
766
    
764
    
767
    MAILTO = ['manas.kapoor@saholic.com','rajneesh.arora@saholic.com']
765
    #MAILTO = ['manas.kapoor@saholic.com','rajneesh.arora@saholic.com']
768
    #MAILTO = ['manas.kapoor@saholic.com']
766
    MAILTO = ['manas.kapoor@saholic.com']
769
    mailServer.login(SENDER, PASSWORD)
767
    mailServer.login(SENDER, PASSWORD)
770
    mailServer.sendmail(PASSWORD, MAILTO, msg.as_string())
768
    mailServer.sendmail(PASSWORD, MAILTO, msg.as_string())
771
 
769
 
772
class __Order:
770
class __Order:
773
    
771
    
Line 1007... Line 1005...
1007
    populateSaholicWeekWiseMap1()
1005
    populateSaholicWeekWiseMap1()
1008
    populateSaholicMonthWiseMap1()
1006
    populateSaholicMonthWiseMap1()
1009
    generateDailyReport()
1007
    generateDailyReport()
1010
    generateWeeklyReport()
1008
    generateWeeklyReport()
1011
    generateMonthlyReport()
1009
    generateMonthlyReport()
-
 
1010
    #sendmail(["manas.kapoor@shop2020.in","rajneesh.arora@saholic.com"], "", TMP_FILE, SUBJECT)
-
 
1011
    sendmail(["manas.kapoor@shop2020.in"], "", TMP_FILE, SUBJECT)
1012
    
1012
    
1013
def to_x_date(java_timestamp):
1013
def to_x_date(java_timestamp):
1014
    try:
1014
    try:
1015
        date = datetime.fromtimestamp(java_timestamp / 1e3)       
1015
        date = datetime.fromtimestamp(java_timestamp / 1e3)       
1016
    except:
1016
    except: