Subversion Repositories SmartDukaan

Rev

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

Rev 17320 Rev 17323
Line 6... Line 6...
6
from sqlalchemy.sql.expression import func, between
6
from sqlalchemy.sql.expression import func, between
7
from datetime import datetime,timedelta
7
from datetime import datetime,timedelta
8
import re
8
import re
9
import traceback
9
import traceback
10
import pymongo
10
import pymongo
-
 
11
from operator import and_
11
 
12
 
12
DataService.initialize(echo=True)
13
DataService.initialize(echo=True)
13
 
14
 
14
DB_HOST = "localhost"
15
DB_HOST = "localhost"
15
DB_USER = "root"
16
DB_USER = "root"
Line 28... Line 29...
28
    
29
    
29
    UNION
30
    UNION
30
   
31
   
31
    select m.userId as user_id,m.brand,m.categoryId as category_id,count(1) as count,"orders" as source,(uw.weightage * count(1)) as weight
32
    select m.userId as user_id,m.brand,m.categoryId as category_id,count(1) as count,"orders" as source,(uw.weightage * count(1)) as weight
32
    from merchantsuborders m join user_segmentation_weigthage uw on "orders"=uw.weightage_type 
33
    from merchantsuborders m join user_segmentation_weigthage uw on "orders"=uw.weightage_type 
33
    where m.categoryId is not null and m.brand is not null and m.userId!=0 group by m.categoryId,m.brand,m.userId
34
    where m.categoryId is not null and m.brand is not null and m.userId!=0 and m.brand not like 'NA' group by m.categoryId,m.brand,m.userId
34
  
35
  
35
    UNION
36
    UNION
36
  
37
  
37
    select fo.user_id,fo.brand,fo.category as category_id,count(fo.id) as count,"orders" as source, (uw.weightage * count(fo.id)) as weight
38
    select fo.user_id,fo.brand,fo.category as category_id,count(fo.id) as count,"orders" as source, (uw.weightage * count(fo.id)) as weight
38
    from flipkartorders fo join user_segmentation_weigthage uw on "orders"=uw.weightage_type 
39
    from flipkartorders fo join user_segmentation_weigthage uw on "orders"=uw.weightage_type 
Line 112... Line 113...
112
    conn = getDbConnection()
113
    conn = getDbConnection()
113
    cursor = conn.cursor()
114
    cursor = conn.cursor()
114
    cursor.execute("select weightage from user_segmentation_weigthage where weightage_type='filters'")
115
    cursor.execute("select weightage from user_segmentation_weigthage where weightage_type='filters'")
115
    result = cursor.fetchall()
116
    result = cursor.fetchall()
116
    filter_weight=result[0][0]
117
    filter_weight=result[0][0]
117
    data = session.query((user_filters)).filter_by(type="brand").all()
118
    data = session.query((user_filters)).filter_by(type="brand").filter(~(user_filters.filters).like('NA')).all()
118
    for d in data:
119
    for d in data:
119
        if userMap.has_key(d.user_id):
120
        if userMap.has_key(d.user_id):
120
            brandMap = userMap.get(d.user_id) 
121
            brandMap = userMap.get(d.user_id) 
121
        else:
122
        else:
122
            brandMap = {}
123
            brandMap = {}