Subversion Repositories SmartDukaan

Rev

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

Rev 13998 Rev 13999
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})
170
    cursor = collection.find({"userId":userId}).sort([("$natural",-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).sort([("$natural",-1)])
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
            del(order["_id"])
179
            orders.append(order)
179
            orders.append(order)
180
        result['data'] = orders
180
        result['data'] = orders