Subversion Repositories SmartDukaan

Rev

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

Rev 15713 Rev 15714
Line 59... Line 59...
59
when ucreated <  date(now()) - interval 3 day and total = 0 and last_active <  date(now()) - interval 3 day then 'INU'
59
when ucreated <  date(now()) - interval 3 day and total = 0 and last_active <  date(now()) - interval 3 day then 'INU'
60
when ucreated >=  date(now()) - interval 3 day and total = 0 and date(last_active) = date(ucreated) then 'FIU'
60
when ucreated >=  date(now()) - interval 3 day and total = 0 and date(last_active) = date(ucreated) then 'FIU'
61
else 'OTH'
61
else 'OTH'
62
end
62
end
63
usersegment, final.*  
63
usersegment, final.*  
64
from (select u.id, u.username, u.first_name, u.mobile_number, u.usergroup_id, ug.groupbasis, count(*),
64
from (select min(u.id), max(u.id), u.username, u.first_name, u.mobile_number, u.usergroup_id, ug.groupbasis, count(*),
65
max(u.created) ucreated, min(u.created) minucreated, max(ua.last_active) last_active, max(ow.created) created, if(sum(ow.total) is null, 0, sum(ow.total)) as total
65
max(u.created) ucreated, min(u.created) minucreated, max(ua.last_active) last_active, max(ow.created) created, if(sum(ow.total) is null, 0, sum(ow.total)) as total
66
from users u left join useractive ua on ua.user_id=u.id left join usergroups ug on ug.id=u.usergroup_id 
66
from users u left join useractive ua on ua.user_id=u.id left join usergroups ug on ug.id=u.usergroup_id 
67
left join (select *, count(*) as total from (select user_id, created from order_view where status in ('ORDER_CREATED', 'DETAIL_CREATED') 
67
left join (select *, count(*) as total from (select user_id, created from order_view where status in ('ORDER_CREATED', 'DETAIL_CREATED') 
68
            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 
68
            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 
69
on ow.user_id = u.id  
69
on ow.user_id = u.id  
Line 157... Line 157...
157
        f.bold = True
157
        f.bold = True
158
        boldStyle.font = f
158
        boldStyle.font = f
159
        column = 0
159
        column = 0
160
        row = 0
160
        row = 0
161
        worksheet.write(row, 0, 'User Segment', boldStyle)
161
        worksheet.write(row, 0, 'User Segment', boldStyle)
-
 
162
        worksheet.write(row, 1, 'First Id', boldStyle)
162
        worksheet.write(row, 1, 'User Id', boldStyle)
163
        worksheet.write(row, 1, 'Last Id', boldStyle)
163
        worksheet.write(row, 2, 'Username', boldStyle)
164
        worksheet.write(row, 2, 'Username', boldStyle)
164
        worksheet.write(row, 3, 'Name', boldStyle)
165
        worksheet.write(row, 3, 'Name', boldStyle)
165
        worksheet.write(row, 4, 'Mobile', boldStyle)
166
        worksheet.write(row, 4, 'Mobile', boldStyle)
166
        worksheet.write(row, 5, 'UserGroupId', boldStyle)
167
        worksheet.write(row, 5, 'UserGroupId', boldStyle)
167
        worksheet.write(row, 6, 'Group basis', boldStyle)
168
        worksheet.write(row, 6, 'Group basis', boldStyle)