Enhance new user cohort optimization by adding language fallback for missing user data and including country in the information retrieval process
This commit is contained in:
@ -713,8 +713,9 @@ def get_new_user_cohort_optimized(
|
||||
|
||||
logger.info(f"login_comp에서 {len(login_comp_collected)}명의 정보 수집 완료")
|
||||
|
||||
# Step 4: log_return_to_lobby 인덱스에서 차선 정보 수집 (auth.id 2순위)
|
||||
missing_uids = [uid for uid in uid_list if uid not in login_comp_collected]
|
||||
# Step 4: log_return_to_lobby 인덱스에서 차선 정보 수집 (auth.id 2순위, language fallback)
|
||||
# login_comp에서 수집되지 않은 유저 + language가 N/A인 유저들 처리
|
||||
missing_uids = [uid for uid in uid_list if uid not in login_comp_collected or cohort[uid]['language'] == 'N/A']
|
||||
|
||||
if missing_uids:
|
||||
logger.info(f"log_return_to_lobby 인덱스에서 {len(missing_uids)}명의 차선 정보 수집 중 (auth.id 2순위)...")
|
||||
@ -743,7 +744,7 @@ def get_new_user_cohort_optimized(
|
||||
"top_hits": {
|
||||
"size": 1,
|
||||
"sort": [{"@timestamp": {"order": "desc"}}],
|
||||
"_source": ["body.nickname", "auth.id"]
|
||||
"_source": ["body.nickname", "auth.id", "country"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -765,12 +766,18 @@ def get_new_user_cohort_optimized(
|
||||
|
||||
info_hit = bucket["info"]["hits"]["hits"][0]["_source"] if bucket["info"]["hits"]["hits"] else {}
|
||||
|
||||
# 차선 정보 업데이트 (login_comp에서 수집되지 않은 유저만)
|
||||
# 차선 정보 업데이트
|
||||
if uid in cohort:
|
||||
# nickname 업데이트 (없는 경우에만)
|
||||
if cohort[uid]['nickname'] == 'N/A':
|
||||
cohort[uid]['nickname'] = info_hit.get('body', {}).get('nickname', 'N/A')
|
||||
|
||||
# language fallback: country 값 사용 (language가 N/A인 경우에만)
|
||||
if cohort[uid]['language'] == 'N/A':
|
||||
country = info_hit.get('country')
|
||||
if country:
|
||||
cohort[uid]['language'] = f"country-{country}"
|
||||
|
||||
# auth.id 수집 (2순위, 없는 경우에만)
|
||||
if cohort[uid]['auth_id'] == 'N/A':
|
||||
auth_id = info_hit.get('auth', {}).get('id')
|
||||
|
||||
Reference in New Issue
Block a user