Enforce campaign launch dates in dashboard data
This commit is contained in:
+10
-1
@@ -56,6 +56,13 @@ if events_path:
|
|||||||
events[key] = events.get(key, 0) + num(event_row.get('event_num'))
|
events[key] = events.get(key, 0) + num(event_row.get('event_num'))
|
||||||
|
|
||||||
config = [r for r in json.load(open('campaign_config.json', encoding='utf-8')) if r['status'].lower() == 'active']
|
config = [r for r in json.load(open('campaign_config.json', encoding='utf-8')) if r['status'].lower() == 'active']
|
||||||
|
|
||||||
|
def active_on(meta, date):
|
||||||
|
"""Respect the Campaign info remark such as 0912新上 for historical backfills."""
|
||||||
|
match = re.search(r'(?<!\d)(\d{2})(\d{2})\s*新上', str(meta.get('remark', '')))
|
||||||
|
if not match:
|
||||||
|
return True
|
||||||
|
return date >= f'{date[:4]}-{match.group(1)}-{match.group(2)}'
|
||||||
experiment = {}
|
experiment = {}
|
||||||
for r in config:
|
for r in config:
|
||||||
if r['group'] == '实验组':
|
if r['group'] == '实验组':
|
||||||
@@ -83,6 +90,7 @@ for raw_row in matrix[1:] if has_header else matrix:
|
|||||||
pkg, source = cell(raw_row, 'pkg').strip(), cell(raw_row, 'source').strip().lower()
|
pkg, source = cell(raw_row, 'pkg').strip(), cell(raw_row, 'source').strip().lower()
|
||||||
campaign = cell(raw_row, 'campaign').strip()
|
campaign = cell(raw_row, 'campaign').strip()
|
||||||
if not pkg or not source or not campaign: continue
|
if not pkg or not source or not campaign: continue
|
||||||
|
date = cell(raw_row, 'date').strip() or target
|
||||||
exp = next((meta for adping, meta in experiment.get((pkg, source), [])
|
exp = next((meta for adping, meta in experiment.get((pkg, source), [])
|
||||||
if re.search(r'(?<!\d)' + re.escape(adping) + r'(?!\d)', campaign)), None)
|
if re.search(r'(?<!\d)' + re.escape(adping) + r'(?!\d)', campaign)), None)
|
||||||
if not exp:
|
if not exp:
|
||||||
@@ -97,7 +105,8 @@ for raw_row in matrix[1:] if has_header else matrix:
|
|||||||
unresolved.append(campaign)
|
unresolved.append(campaign)
|
||||||
continue
|
continue
|
||||||
group, shown, adping = '对照组', 'General campaign', ''
|
group, shown, adping = '对照组', 'General campaign', ''
|
||||||
date = cell(raw_row, 'date').strip() or target
|
if not active_on(meta, date):
|
||||||
|
continue
|
||||||
required = event_names(meta.get('kpi',''))
|
required = event_names(meta.get('kpi',''))
|
||||||
if not required or (date, source) not in covered_scopes:
|
if not required or (date, source) not in covered_scopes:
|
||||||
event = None
|
event = None
|
||||||
|
|||||||
Reference in New Issue
Block a user