Subversion Repositories SmartDukaan

Rev

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

Rev 14000 Rev 14001
Line 165... Line 165...
165
    if window==None:
165
    if window==None:
166
        window = 50
166
        window = 50
167
    result = {}
167
    result = {}
168
    skip = (page-1)*window
168
    skip = (page-1)*window
169
    collection = get_mongo_connection().Dtr.merchantOrder
169
    collection = get_mongo_connection().Dtr.merchantOrder
170
    cursor = collection.find({"userId":userId}).sort("$natural",-1)
170
    cursor = collection.find({"userId":userId}).sort("_id",-1)
171
    total_count = cursor.count()
171
    total_count = cursor.count()
172
    pages = total_count/window + (0 if total_count%window==0 else 1)  
172
    pages = total_count/window + (0 if total_count%window==0 else 1)  
173
    print "total_count", total_count
173
    print "total_count", total_count
174
    if total_count > skip:
174
    if total_count > skip:
175
        cursor = cursor.skip(skip).limit(window)
175
        cursor = cursor.skip(skip).limit(window)
176
        orders = []
176
        orders = []
177
        for order in cursor:
177
        for order in cursor:
178
            del(order["_id"])
178
            print order['orderId']
179
            orders.append(order)
-
 
180
        result['data'] = orders
179
        result['data'] = orders
181
        result['window'] = window
180
        result['window'] = window
182
        result['totalCount'] = total_count 
181
        result['totalCount'] = total_count 
183
        result['currCount'] = cursor.count()
182
        result['currCount'] = cursor.count()
184
        result['totalPages'] = pages
183
        result['totalPages'] = pages