| Line 49... |
Line 49... |
| 49 |
left join usergroups ug on ug.id=u.usergroup_id
|
49 |
left join usergroups ug on ug.id=u.usergroup_id
|
| 50 |
left join (select distinct user_id from price_preferences) pp on pp.user_id=u.id
|
50 |
left join (select distinct user_id from price_preferences) pp on pp.user_id=u.id
|
| 51 |
left join (select distinct user_id from brand_preferences) bp on bp.user_id=u.id
|
51 |
left join (select distinct user_id from brand_preferences) bp on bp.user_id=u.id
|
| 52 |
left join (select *, count(*) as total from (select user_id, created from order_view where status in ('ORDER_CREATED', 'DETAIL_CREATED') union all (select user_id, created from flipkartorders where date(created) >'2015-03-22') order by created desc) as a1 group by user_id) as ow on ow.user_id = u.id
|
52 |
left join (select *, count(*) as total from (select user_id, created from order_view where status in ('ORDER_CREATED', 'DETAIL_CREATED') union all (select user_id, created from flipkartorders where date(created) >'2015-03-22') order by created desc) as a1 group by user_id) as ow on ow.user_id = u.id
|
| 53 |
left join user_activity_status uas on uas.user_id=u.id
|
53 |
left join user_activity_status uas on uas.user_id=u.id
|
| 54 |
left join all_user_addresses aua on aua.user_id=u.id
|
54 |
left join (select * from (select * from all_user_addresses order by source) s group by user_ud)aua on aua.user_id=u.id
|
| 55 |
left join (select * from (select user_id, versioncode from devices order by created desc) c group by user_id) d on d.user_id=u.id
|
55 |
left join (select * from (select user_id, versioncode from devices order by created desc) c group by user_id) d on d.user_id=u.id
|
| 56 |
left join retailerlinks rl on rl.user_id=u.id left join retailers r on r.id=rl.retailer_id where (lower(u.referrer) not like 'emp%' or u.utm_campaign is not null) and u.activated = 1) final;
|
56 |
left join retailerlinks rl on rl.user_id=u.id left join retailers r on r.id=rl.retailer_id where (lower(u.referrer) not like 'emp%' or u.utm_campaign is not null) and u.activated = 1) final;
|
| 57 |
"""
|
57 |
"""
|
| 58 |
GROUP_SEGMENTATION_QUERY = """
|
58 |
GROUP_SEGMENTATION_QUERY = """
|
| 59 |
select case
|
59 |
select case
|
| Line 96... |
Line 96... |
| 96 |
cursor = conn.cursor()
|
96 |
cursor = conn.cursor()
|
| 97 |
# Execute the SQL command
|
97 |
# Execute the SQL command
|
| 98 |
# Fetch source id.
|
98 |
# Fetch source id.
|
| 99 |
cursor.execute(selectSql)
|
99 |
cursor.execute(selectSql)
|
| 100 |
result = cursor.fetchall()
|
100 |
result = cursor.fetchall()
|
| 101 |
workbook = xlwt.Workbook()
|
101 |
workbook = xlwt.Workbook("utf-8")
|
| 102 |
worksheet = workbook.add_sheet("Segmented User")
|
102 |
worksheet = workbook.add_sheet("Segmented User")
|
| 103 |
boldStyle = xlwt.XFStyle()
|
103 |
boldStyle = xlwt.XFStyle()
|
| 104 |
f = xlwt.Font()
|
104 |
f = xlwt.Font()
|
| 105 |
f.bold = True
|
105 |
f.bold = True
|
| 106 |
boldStyle.font = f
|
106 |
boldStyle.font = f
|