Subversion Repositories SmartDukaan

Rev

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

Rev 16216 Rev 16258
Line 33... Line 33...
33
DB_NAME = "dtr"
33
DB_NAME = "dtr"
34
 
34
 
35
INSERT_QUERY= """
35
INSERT_QUERY= """
36
INSERT INTO dial2verifyStatus (session_id, api_key, mobile_number, verification_status, transaction_time, verification_time) VALUES ('%s', '%s', '%s', '%s', '%s', '%s');"""
36
INSERT INTO dial2verifyStatus (session_id, api_key, mobile_number, verification_status, transaction_time, verification_time) VALUES ('%s', '%s', '%s', '%s', '%s', '%s');"""
37
 
37
 
-
 
38
CHECK_VERIFIED_USERS="""
-
 
39
select a.id,a.verification_time from  (select d.mobile_number,u.mobile_number as ue,u.id,u.email,d.verification_status, d.verification_time,u.mobile_number_last_updated, timediff(d.verification_time,u.mobile_number_last_updated) as ti,u.mobile_verified  from dial2verifyStatus d join users u on d.mobile_number=u.mobile_number  where d.verification_status='Verified' and u.mobile_verified!=1  and lower(u.referrer) not like 'emp%'  and timediff(d.verification_time,u.mobile_number_last_updated) < time('00:05:00')  and timediff(d.verification_time,u.mobile_number_last_updated) >= time('00:00:00')) a  where a.mobile_number=a.ue  and date(a.verification_time)<=(curdate() - interval 1 day) group by a.id;
-
 
40
"""
-
 
41
 
-
 
42
UPDATE_USER_VERIFIED_STATUS="""
-
 
43
update users set mobile_verified=1, mobile_number_last_updated='%s' where id=%s
-
 
44
"""
-
 
45
 
38
def getDbConnection():
46
def getDbConnection():
39
    return MySQLdb.connect(options.dbHost, DB_USER, DB_PASSWORD, DB_NAME)
47
    return MySQLdb.connect(options.dbHost, DB_USER, DB_PASSWORD, DB_NAME)
40
                
48
                
41
def insertVerificationData(filePath):
49
def insertVerificationData(filePath):
42
    session_id=''
50
    session_id=''
Line 81... Line 89...
81
                conn.commit()
89
                conn.commit()
82
            else:
90
            else:
83
                squery=INSERT_QUERY % (session_id,api_key,mobile_number_new[0:10],verifcation_status,ttime.strftime('%Y-%m-%d %H:%M:%S'),vtime)
91
                squery=INSERT_QUERY % (session_id,api_key,mobile_number_new[0:10],verifcation_status,ttime.strftime('%Y-%m-%d %H:%M:%S'),vtime)
84
                cur.execute(squery)
92
                cur.execute(squery)
85
                conn.commit()                
93
                conn.commit()                
-
 
94
    conn.close()
86
 
95
    
87
def deleteDial2VerifyRecords():
96
def deleteDial2VerifyRecords():
88
    conn = getDbConnection()
97
    conn = getDbConnection()
89
    datesql="delete from dial2verifyStatus"
98
    datesql="delete from dial2verifyStatus"
90
    cursor = conn.cursor()
99
    cursor = conn.cursor()
91
    cursor.execute(datesql)
100
    cursor.execute(datesql)
92
    conn.commit()           
101
    conn.commit()
-
 
102
    conn.close()
-
 
103
         
-
 
104
def checkUsersStatus():
-
 
105
    conn = getDbConnection()
-
 
106
    datesql=CHECK_VERIFIED_USERS
-
 
107
    cursor = conn.cursor()
-
 
108
    cursor.execute(datesql)
-
 
109
    result = cursor.fetchall()
-
 
110
    for r in result:
-
 
111
        updateUserStatus(r[0],r[1])
-
 
112
    conn.close()
-
 
113
 
-
 
114
def updateUserStatus(userId,updateDate):
-
 
115
    conn = getDbConnection()
-
 
116
    datesql=UPDATE_USER_VERIFIED_STATUS%(updateDate,userId)
-
 
117
    print datesql
-
 
118
    cursor = conn.cursor()
-
 
119
    cursor.execute(datesql)
-
 
120
    conn.commit()
-
 
121
    conn.close()
-
 
122
                  
93
                    
123
                    
94
def main():
124
def main():
95
    filePath = Dial2VerifyFile.main()
125
    filePath = Dial2VerifyFile.main()
96
    deleteDial2VerifyRecords()
126
    deleteDial2VerifyRecords()
97
    insertVerificationData(filePath)
127
    insertVerificationData(filePath)
-
 
128
    checkUsersStatus()
98
 
129
    
99
if __name__ == '__main__':
130
if __name__ == '__main__':
100
    main()
-
 
101
131
    main()
-
 
132