|
@@ -434,7 +434,7 @@ class CampaignView(View):
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
def get_user_behavior_log(self, request_dict, response):
|
|
def get_user_behavior_log(self, request_dict, response):
|
|
- campaign_ids = request_dict.get('campaign_ids', None)
|
|
|
|
|
|
+ campaign_ids = json.loads(request_dict.get('campaign_id', '[]'))
|
|
start_time = request_dict.get('start_time', None)
|
|
start_time = request_dict.get('start_time', None)
|
|
end_time = request_dict.get('end_time', None)
|
|
end_time = request_dict.get('end_time', None)
|
|
if not all([start_time, end_time]):
|
|
if not all([start_time, end_time]):
|
|
@@ -443,22 +443,39 @@ class CampaignView(View):
|
|
open_screen_campaign_qs = OpenScreenCampaign.objects.filter(
|
|
open_screen_campaign_qs = OpenScreenCampaign.objects.filter(
|
|
update_time__range=[int(start_time), int(end_time)])
|
|
update_time__range=[int(start_time), int(end_time)])
|
|
|
|
|
|
- if campaign_ids is not None:
|
|
|
|
- open_screen_campaign_qs = open_screen_campaign_qs.filter(Q(campaign_id_id__in=json.loads(campaign_ids)))
|
|
|
|
-
|
|
|
|
- open_screen_campaign_qs = open_screen_campaign_qs.select_related('campaign_id').annotate(
|
|
|
|
- campaign_name=F('campaign_id__campaign_name'),
|
|
|
|
- campaign_type=F('campaign_id__campaign_type'),
|
|
|
|
- campaign_status=F('campaign_id__status'),
|
|
|
|
- start_date=F('campaign_id__campaign_start_date'),
|
|
|
|
- end_date=F('campaign_id__campaign_end_date'),
|
|
|
|
- start_time=F('campaign_id__campaign_show_stime'),
|
|
|
|
- end_time=F('campaign_id__campaign_show_etime')
|
|
|
|
- ).values('id', 'user_id', 'status', 'update_time', 'create_time', 'campaign_id', 'campaign_name',
|
|
|
|
- 'campaign_type', 'campaign_status', 'start_date', 'end_date', 'start_time', 'end_time')
|
|
|
|
|
|
+ if campaign_ids:
|
|
|
|
+ open_screen_campaign_qs = open_screen_campaign_qs.filter(
|
|
|
|
+ campaign_id__in=campaign_ids, campaign_id__status__in=[0, 1],
|
|
|
|
+ campaign_id__campaign_type__contains=[1]
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ open_screen_campaign_qs = (open_screen_campaign_qs.
|
|
|
|
+ select_related('campaign_id').
|
|
|
|
+ values('id', 'user_id', 'status', 'update_time', 'create_time',
|
|
|
|
+ 'campaign_id', 'campaign_id__campaign_name', 'campaign_id__campaign_type',
|
|
|
|
+ 'campaign_id__status',
|
|
|
|
+ 'campaign_id__campaign_start_date', 'campaign_id__campaign_end_date',
|
|
|
|
+ 'campaign_id__campaign_show_stime', 'campaign_id__campaign_show_etime'))
|
|
if not open_screen_campaign_qs.exists():
|
|
if not open_screen_campaign_qs.exists():
|
|
return response.json(0, {'list': []})
|
|
return response.json(0, {'list': []})
|
|
- campaigns_list = list(open_screen_campaign_qs)
|
|
|
|
|
|
+ campaigns_list = []
|
|
|
|
+ for campaign in open_screen_campaign_qs:
|
|
|
|
+ renamed_campaign = {
|
|
|
|
+ 'id': campaign['id'],
|
|
|
|
+ 'user_id': campaign['user_id'],
|
|
|
|
+ 'status': campaign['status'],
|
|
|
|
+ 'update_time': campaign['update_time'],
|
|
|
|
+ 'create_time': campaign['create_time'],
|
|
|
|
+ 'campaign_id': campaign['campaign_id'],
|
|
|
|
+ 'campaign_name': campaign['campaign_id__campaign_name'],
|
|
|
|
+ 'campaign_type': 1,
|
|
|
|
+ 'campaign_status': campaign['campaign_id__status'],
|
|
|
|
+ 'start_date': campaign['campaign_id__campaign_start_date'],
|
|
|
|
+ 'end_date': campaign['campaign_id__campaign_end_date'],
|
|
|
|
+ 'start_time': campaign['campaign_id__campaign_show_stime'],
|
|
|
|
+ 'end_time': campaign['campaign_id__campaign_show_etime']
|
|
|
|
+ }
|
|
|
|
+ campaigns_list.append(renamed_campaign)
|
|
return response.json(0, {'list': campaigns_list})
|
|
return response.json(0, {'list': campaigns_list})
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|