Subversion Repositories SmartDukaan

Rev

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

Rev 13801 Rev 13803
Line 2... Line 2...
2
from datetime import datetime
2
from datetime import datetime
3
from dtr.utils.utils import to_java_date
3
from dtr.utils.utils import to_java_date
4
from operator import itemgetter 
4
from operator import itemgetter 
5
 
5
 
6
con = None
6
con = None
7
sortDirection = {'asc':pymongo.ASCENDING,'dsc':pymongo.DESCENDING}
-
 
8
 
7
 
9
def get_mongo_connection(host='localhost', port=27017):
8
def get_mongo_connection(host='localhost', port=27017):
10
    global con
9
    global con
11
    if con is None:
10
    if con is None:
12
        print "Establishing connection %s host and port %d" %(host,port)
11
        print "Establishing connection %s host and port %d" %(host,port)
Line 116... Line 115...
116
        return result
115
        return result
117
 
116
 
118
def getDeals(category_id, offset, limit, sort, direction):
117
def getDeals(category_id, offset, limit, sort, direction):
119
    rank = 1
118
    rank = 1
120
    deals = {}
119
    deals = {}
121
    print "***",len(sort)
-
 
122
    print "****",len(direction)
-
 
123
    if len(sort) * len(direction) == 0:
120
    if sort is None or direction is None:
124
        sortField = "totalPoints"
121
        sortField = "totalPoints"
125
        direct = sortDirection.get('dsc')
122
        direct = -1
126
    else:
123
    else:
127
        sortField = sort
124
        sortField = sort
128
        direct = sortDirection.get(direction)
125
        direct = direction
129
    print category_id
126
    print category_id
130
    print offset
127
    print offset
131
    print limit
128
    print limit
132
    print sortField
129
    print sortField
133
    print direct
130
    print direct