Skip to content

Commit

Permalink
chore: add clarifying comments for dataset API key filtering based on…
Browse files Browse the repository at this point in the history
… created_by field
  • Loading branch information
hgbdev committed Dec 7, 2024
1 parent 4a1777c commit 4c20b92
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/controllers/console/datasets/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ def get(self):
.all()
)

# Only return keys created by current user or created_by none (for old keys do not have created_by)
keys = [key for key in keys if key.created_by == current_user.id or key.created_by is None]

return {"items": keys}
Expand All @@ -557,6 +558,7 @@ def post(self):
.all()
)

# Only count keys created by current user or created_by none (for old keys do not have created_by)
current_key_count = len([key for key in keys if key.created_by == current_user.id or key.created_by is None])

if current_key_count >= self.max_keys:
Expand Down

0 comments on commit 4c20b92

Please sign in to comment.