-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
중복순위 처리버그 수정 #68
base: main
Are you sure you want to change the base?
중복순위 처리버그 수정 #68
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,12 +247,12 @@ def check_season(): | |
with TaskSessionLocal() as db: | ||
raid_id = get_latest_raid_id(db) | ||
total_count = data_provider_client.get_total_users_count(raid_id) | ||
sync_count = offset = get_reward_count(db, raid_id) | ||
sync_count = get_reward_count(db, raid_id) | ||
offset = 0 | ||
# 최신 시즌 동기화 처리 | ||
if sync_count == total_count: | ||
upload_tx_list(raid_id) | ||
raid_id += 1 | ||
offset = 0 | ||
save_ranking_rewards( | ||
raid_id=raid_id, payload_size=500, recipients_size=50, offset=offset | ||
) | ||
|
@@ -272,11 +272,27 @@ def save_ranking_rewards( | |
results: List[RankingRewardWithAgentDictionary] = [] | ||
time_stamp = get_next_month_last_day() | ||
memo = "world boss ranking rewards by world boss signer" | ||
target_avatar_addresses = [] | ||
with TaskSessionLocal() as db: | ||
start_nonce = get_next_tx_nonce(db) | ||
result = data_provider_client.get_ranking_rewards( | ||
raid_id, NetworkType.MAIN, offset, payload_size | ||
) | ||
while True: | ||
result = data_provider_client.get_ranking_rewards( | ||
raid_id, NetworkType.MAIN, offset, payload_size | ||
) | ||
exist_avatar_addresses = [ | ||
i | ||
for i, in db.query(WorldBossReward.avatar_address).filter_by( | ||
raid_id=raid_id | ||
) | ||
] | ||
avatar_addresses = [r["raider"]["address"] for r in result] | ||
target_avatar_addresses = [ | ||
i for i in avatar_addresses if i not in exist_avatar_addresses | ||
] | ||
Comment on lines
+289
to
+291
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 기왕에 list 만드느라 loop 도는거 |
||
if len(target_avatar_addresses) > 0: | ||
break | ||
else: | ||
offset += payload_size | ||
Comment on lines
+294
to
+295
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. offset 을 계속 증가시키다가 DP 에서 가져오는 값이 없어지면 계속 else 를 타면서 무한 loop 에 빠질 수 있을 것 같습니다. DP 에서 가져올 게 더 없는 경우 탈출시키는 게 필요하지 않을까요? |
||
rewards = update_agent_address( | ||
result, raid_id, NetworkType.MAIN, offset, payload_size | ||
) | ||
|
@@ -288,6 +304,8 @@ def save_ranking_rewards( | |
raider: RaiderWithAgentDictionary = r["raider"] | ||
ranking = raider["ranking"] | ||
avatar_address = raider["address"] | ||
if avatar_address not in target_avatar_addresses: | ||
continue | ||
reward_dict_list: List[RewardDictionary] = r["rewards"] | ||
for reward_dict in reward_dict_list: | ||
nonce = start_nonce + int(i / recipients_size) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이건 loop 밖에서 한번만 가져와도 될 것 같습니다. offset 을 딱히 사용하는 것도 아니고 full query 라서 반복할 필요가 없을 것 같네요.