Skip to content

Commit

Permalink
prefer count() over len
Browse files Browse the repository at this point in the history
  • Loading branch information
furlongm committed Sep 28, 2024
1 parent 7d50042 commit 02b82ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hosts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class Meta:
'updated_at', 'bugfix_update_count', 'security_update_count')

def get_bugfix_update_count(self, obj):
return len([u for u in obj.updates.all() if not u.security])
return obj.updates.filter(security=False).count()

def get_security_update_count(self, obj):
return len([u for u in obj.updates.all() if u.security])
return obj.updates.filter(security=True).count()


class HostRepoSerializer(serializers.HyperlinkedModelSerializer):
Expand Down

0 comments on commit 02b82ee

Please sign in to comment.