Subversion Repositories SmartDukaan

Rev

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

Rev 17125 Rev 17126
Line 72... Line 72...
72
PASSWORD = "5h0p2o2o"
72
PASSWORD = "5h0p2o2o"
73
SUBJECT = "User Activity Report for " + date.today().isoformat()
73
SUBJECT = "User Activity Report for " + date.today().isoformat()
74
SMTP_SERVER = "smtp.gmail.com"
74
SMTP_SERVER = "smtp.gmail.com"
75
SMTP_PORT = 587    
75
SMTP_PORT = 587    
76
 
76
 
77
DATE_QUERY="""
-
 
78
SELECT date(d.visited) from daily_visitors d 
-
 
79
join users u where u.id=d.user_id AND 
-
 
80
(LOWER(u.referrer) NOT LIKE  'emp%' OR u.utm_campaign is not NULL) AND u.activated =1
-
 
81
AND date(d.visited) > '2015-03-08' group by visited ;
-
 
82
"""
-
 
83
 
-
 
84
MONTH_QUERY="""
77
MONTH_QUERY="""
85
SELECT month(d.visited) from daily_visitors d 
78
SELECT month(d.visited) from daily_visitors d 
86
join users u on u.id=d.user_id where 
79
join users u on u.id=d.user_id where 
87
(LOWER(u.referrer) NOT LIKE  'emp%' OR u.utm_campaign is not NULL) AND u.activated =1
80
(LOWER(u.referrer) NOT LIKE  'emp%' OR u.utm_campaign is not NULL) AND u.activated =1
88
group by month(d.visited);
81
group by month(d.visited);
Line 300... Line 293...
300
def getDbConnection():
293
def getDbConnection():
301
    return MySQLdb.connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
294
    return MySQLdb.connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
302
 
295
 
303
 
296
 
304
def generateDailyReport():
297
def generateDailyReport():
305
    datesql= DATE_QUERY
-
 
306
    dnruSql = DNRU_QUERY
298
    dnruSql = DNRU_QUERY
307
    dauSql = DAU_QUERY
299
    dauSql = DAU_QUERY
308
    dabSql = DAB_QUERY
300
    dabSql = DAB_QUERY
309
    dtoSql = DTO_QUERY
301
    dtoSql = DTO_QUERY
310
    conn = getDbConnection()
302
    conn = getDbConnection()
311
 
303
 
312
    cursor = conn.cursor()
304
    cursor = conn.cursor()
313
    cursor.execute(datesql)
-
 
314
    result = cursor.fetchall()
-
 
315
    global workbook
305
    global workbook
316
    workbook = xlwt.Workbook()
306
    workbook = xlwt.Workbook()
317
    worksheet = workbook.add_sheet("User")
307
    worksheet = workbook.add_sheet("User")
318
    boldStyle = xlwt.XFStyle()
308
    boldStyle = xlwt.XFStyle()
319
    f = xlwt.Font()
309
    f = xlwt.Font()
Line 342... Line 332...
342
#             if data.strip() =='2015/09/29':
332
#             if data.strip() =='2015/09/29':
343
#                 worksheet.write(row,column)
333
#                 worksheet.write(row,column)
344
#             worksheet.write(row, column, int(data) if type(data) is float else data, date_format if type(data) is date else default_format)
334
#             worksheet.write(row, column, int(data) if type(data) is float else data, date_format if type(data) is date else default_format)
345
#             column += 1
335
#             column += 1
346
 
336
 
347
    d = datetime(2015, 3, 7)
337
    d = datetime(2015, 3, 8)
348
    i=1 
338
    i=1 
349
    a= datetime.today()
339
    a= datetime.today()
350
    todayDate = a.strftime('%Y/%m/%d')    
340
    todayDate = a.strftime('%Y/%m/%d')    
351
    while(True):
341
    while(True):
352
        row += 1
342
        row += 1