Subversion Repositories SmartDukaan

Rev

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

Rev 13910 Rev 13911
Line 152... Line 152...
152
        outer_query.append({'category_id':category_id})
152
        outer_query.append({'category_id':category_id})
153
    if sort is None or direction is None:
153
    if sort is None or direction is None:
154
        direct = -1
154
        direct = -1
155
        print outer_query
155
        print outer_query
156
        data = list(get_mongo_connection().Catalog.Deals.find({"$and":outer_query}).sort([('totalPoints',direct),('bestSellerPoints',direct),('nlcPoints',direct),('rank',direct)]).skip(offset).limit(limit))
156
        data = list(get_mongo_connection().Catalog.Deals.find({"$and":outer_query}).sort([('totalPoints',direct),('bestSellerPoints',direct),('nlcPoints',direct),('rank',direct)]).skip(offset).limit(limit))
157
        for temp in data:
-
 
158
            print temp['_id'],
-
 
159
            print '\t',
-
 
160
            print temp['totalPoints'],
-
 
161
            print '\t',
-
 
162
            print temp['bestSellerPoints'],
-
 
163
            print '\t',
-
 
164
            print temp['nlcPoints'],
-
 
165
            print '\t',
-
 
166
            print temp['rank']
-
 
167
    else:
157
    else:
168
        print outer_query
158
        print outer_query
169
        direct = direction
159
        direct = direction
170
        if sort == "bestSellerPoints":
160
        if sort == "bestSellerPoints":
171
            print "yes,sorting by bestSellerPoints"
161
            print "yes,sorting by bestSellerPoints"
172
            data = list(get_mongo_connection().Catalog.Deals.find({"$and":outer_query}).sort([('bestSellerPoints',direct),('rank',direct),('nlcPoints',direct)]).skip(offset).limit(limit))
162
            data = list(get_mongo_connection().Catalog.Deals.find({"$and":outer_query}).sort([('bestSellerPoints',direct),('rank',direct),('nlcPoints',direct)]).skip(offset).limit(limit))
173
            for temp in data:
-
 
174
                print temp['_id'],
-
 
175
                print '\t',
-
 
176
                print temp['totalPoints'],
-
 
177
                print '\t',
-
 
178
                print temp['bestSellerPoints'],
-
 
179
                print '\t',
-
 
180
                print temp['nlcPoints'],
-
 
181
                print '\t',
-
 
182
                print temp['rank']
-
 
183
        else:
163
        else:
184
            data = list(get_mongo_connection().Catalog.Deals.find({"$and":outer_query}).sort([(sort,direct)]).skip(offset).limit(limit))
164
            data = list(get_mongo_connection().Catalog.Deals.find({"$and":outer_query}).sort([(sort,direct)]).skip(offset).limit(limit))
185
            for temp in data:
-
 
186
                print temp['_id'],
-
 
187
                print '\t',
-
 
188
                print temp['available_price']
-
 
189
    for d in data:
165
    for d in data:
190
        item = list(get_mongo_connection().Catalog.MasterData.find({'_id':d['_id']}))
166
        item = list(get_mongo_connection().Catalog.MasterData.find({'_id':d['_id']}))
191
        if not deals.has_key(item[0]['identifier']):
167
        if not deals.has_key(item[0]['identifier']):
192
            item[0]['dealRank'] = rank 
168
            item[0]['dealRank'] = rank 
193
            deals[item[0]['identifier']] = item[0]
169
            deals[item[0]['identifier']] = item[0]