Subversion Repositories SmartDukaan

Rev

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

Rev 14602 Rev 14615
Line 44... Line 44...
44
ORDER_HTML_QUERY = '''
44
ORDER_HTML_QUERY = '''
45
select rawhtml from orders where id = %s
45
select rawhtml from orders where id = %s
46
'''
46
'''
47
 
47
 
48
 
48
 
-
 
49
 
-
 
50
 
49
def getOrders(page=1, window=50):
51
def getOrders(page=1, window=50):
50
    try:
52
    try:
51
        conn = getDbConnection()
53
        conn = getDbConnection()
52
        if page==None:
54
        if page==None:
53
            page = 1
55
            page = 1
Line 89... Line 91...
89
        return result[0][0]
91
        return result[0][0]
90
    except:
92
    except:
91
        traceback.print_exc()
93
        traceback.print_exc()
92
    finally:
94
    finally:
93
        conn.close()
95
        conn.close()
94
 
96
        
95
def getOrdersAfterDate(afterDate, storeId):
97
def getOrdersAfterDate(afterDate, storeId):
96
    try:
98
    try:
97
        conn = getDbConnection()
99
        conn = getDbConnection()
98
        cursor = conn.cursor()
100
        cursor = conn.cursor()
99
        afterDate = datetime.strftime(afterDate,"%Y-%m-%d")
101
        afterDate = datetime.strftime(afterDate,"%Y-%m-%d")
Line 122... Line 124...
122
        query = "select o.* from users u join order_view o on u.id = o.user_id join clicks c on c.user_id = u.id where c.tag = '%s' and o.status='ORDER_CREATED' and o.store_id=%s"
124
        query = "select o.* from users u join order_view o on u.id = o.user_id join clicks c on c.user_id = u.id where c.tag = '%s' and o.status='ORDER_CREATED' and o.store_id=%s"
123
        cursor.execute(query%(tagName, storeId))
125
        cursor.execute(query%(tagName, storeId))
124
        result = cursor.fetchall()
126
        result = cursor.fetchall()
125
        return result
127
        return result
126
    finally:
128
    finally:
127
        conn.close() 
129
        conn.close()
128
 
130
 
129
def main():
131
def main():
130
    print getOrdersAfterDate(datetime.now() - timedelta(days=10), 3)
132
    print getOrdersAfterDate(datetime.now() - timedelta(days=10), 3)
131
 
133
 
-
 
134
def fetchResult(query, *params):
-
 
135
    try:
-
 
136
        conn = getDbConnection()
-
 
137
        cursor = conn.cursor()
-
 
138
        cursor.execute(query.format(params))
-
 
139
        result = cursor.fetchall()
-
 
140
        return result
-
 
141
    finally:
-
 
142
        conn.close() 
132
 
143
 
133
if __name__ == '__main__':
144
if __name__ == '__main__':
134
    main()
145
    main()
135
146