Skip to content
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

fix(jobs): AttributeError: 'list' object has no attribute 'items' #1436

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/jobs/record_usages.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ def record_user_usages():
users_usage = list({"uid": uid, "value": value} for uid, value in users_usage.items())
if not users_usage:
return

with GetDB() as db:
user_admin_map = dict(db.query(User.id, User.admin_id).all())

admin_usage = defaultdict(int)
for uid, usage in users_usage.items():
admin_id = user_admin_map.get(uid)
for user_usage in users_usage:
admin_id = user_admin_map.get(user_usage["uid"])
if admin_id:
admin_usage[admin_id] += usage
admin_usage[admin_id] += user_usage["value"]

# record users usage
with GetDB() as db:
Expand All @@ -169,7 +169,7 @@ def record_user_usages():

if DISABLE_RECORDING_NODE_USAGE:
return

admin_data = [{"admin_id": admin_id, "value": value} for admin_id, value in admin_usage.items()]
if admin_data:
admin_update_stmt = update(Admin). \
Expand Down