Subversion Repositories SmartDukaan

Rev

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

Rev 14852 Rev 14997
Line 1059... Line 1059...
1059
            val['brand'] = ""
1059
            val['brand'] = ""
1060
            val['source_product_name'] = ""
1060
            val['source_product_name'] = ""
1061
            val['skuBundleId'] = ""
1061
            val['skuBundleId'] = ""
1062
        data.append(val)
1062
        data.append(val)
1063
    return data
1063
    return data
-
 
1064
 
-
 
1065
def getBrandsForFilter(category_id):
-
 
1066
    if mc.get("brandFilter") is None:
-
 
1067
        tabData, mobData = [], []
-
 
1068
        mobileDeals = get_mongo_connection().Catalog.Deals.aggregate([
-
 
1069
                                                                      {"$match":{"category_id":3,"showDeal":1}
-
 
1070
                                                                    },
-
 
1071
                                                                 {"$group" : 
-
 
1072
                                                                  {'_id':{'brand_id':'$brand_id','brand':'$brand'},'count':{'$sum':1}}
-
 
1073
                                                                  }
-
 
1074
                                                                ])
-
 
1075
        
-
 
1076
        tabletDeals = get_mongo_connection().Catalog.Deals.aggregate([
-
 
1077
                                                                      {"$match":{"category_id":5,"showDeal":1}
-
 
1078
                                                                    },
-
 
1079
                                                                 {"$group" : 
-
 
1080
                                                                  {'_id':{'brand_id':'$brand_id','brand':'$brand'},'count':{'$sum':1}}
-
 
1081
                                                                  }
-
 
1082
                                                                ])
-
 
1083
        
-
 
1084
        allDeals = get_mongo_connection().Catalog.Deals.aggregate([
-
 
1085
                                                                   {"$match":{"showDeal":1}
-
 
1086
                                                                    },
-
 
1087
                                                                 {"$group" : 
-
 
1088
                                                                  {'_id':{'brand_id':'$brand_id','brand':'$brand'},'count':{'$sum':1}}
-
 
1089
                                                                  }
-
 
1090
                                                                ])
-
 
1091
        #print mobileDeals
-
 
1092
        #print "==========Mobile data ends=========="
-
 
1093
        
-
 
1094
        #print tabletDeals
-
 
1095
        #print "==========Tablet data ends=========="
-
 
1096
        
-
 
1097
        #print allDeals
-
 
1098
        #print "==========All deal data ends========="
-
 
1099
        
-
 
1100
        for mobileDeal in mobileDeals['result']:
-
 
1101
            if mobileDeal.get('_id').get('brand_id') != 0:
-
 
1102
                tempMap = {}
-
 
1103
                tempMap['brand'] = mobileDeal.get('_id').get('brand')
-
 
1104
                tempMap['brand_id'] = mobileDeal.get('_id').get('brand_id')
-
 
1105
                tempMap['count'] = mobileDeal.get('count')
-
 
1106
                mobData.append(tempMap)
-
 
1107
        
-
 
1108
        for tabletDeal in tabletDeals['result']:
-
 
1109
            if tabletDeal.get('_id').get('brand_id') != 0:
-
 
1110
                tempMap = {}
-
 
1111
                tempMap['brand'] = tabletDeal.get('_id').get('brand')
-
 
1112
                tempMap['brand_id'] = tabletDeal.get('_id').get('brand_id')
-
 
1113
                tempMap['count'] = tabletDeal.get('count')
-
 
1114
                tabData.append(tempMap)
-
 
1115
        
-
 
1116
        
-
 
1117
        brandMap = {}
-
 
1118
        for allDeal in allDeals['result']:
-
 
1119
            if allDeal.get('_id').get('brand_id') != 0:
-
 
1120
                if brandMap.has_key(allDeal.get('_id').get('brand')):
-
 
1121
                    brand_ids = brandMap.get(allDeal.get('_id').get('brand'))
-
 
1122
                    brand_ids.append(allDeal.get('_id').get('brand_id'))
-
 
1123
                    brandMap[allDeal.get('_id').get('brand')] = brand_ids
-
 
1124
                else:
-
 
1125
                    temp = []
-
 
1126
                    temp.append(allDeal.get('_id').get('brand_id'))
-
 
1127
                    brandMap[allDeal.get('_id').get('brand')] = temp
-
 
1128
      
-
 
1129
        mc.set("brandFilter",{0:brandMap, 3:mobData, 5:tabData}, 600)  
-
 
1130
    
-
 
1131
    return mc.get("brandFilter").get(category_id)                
-
 
1132
 
-
 
1133
        
-
 
1134
        
1064
        
1135
        
1065
def main():
1136
def main():
1066
    print __getBundledSkusfromSku(1)
1137
    print (getBrandsForFilter(3))
1067
    
1138
    
1068
    
1139
    
1069
if __name__=='__main__':
1140
if __name__=='__main__':
1070
    main()
1141
    main()