Fix crash on user on None min_package_rank

This commit is contained in:
rubenwardy 2021-07-25 18:30:10 +01:00
parent 76675ad76b
commit 95bd1a50d9
2 changed files with 3 additions and 2 deletions

@ -75,7 +75,8 @@ def profile(username):
all_package_ranks = db.session.query(
Package.author_id,
func.rank().over(order_by=db.desc(Package.score)) \
.label('rank')).order_by(db.asc(text("rank"))).subquery()
.label('rank')).order_by(db.asc(text("rank"))) \
.filter_by(state=PackageState.APPROVED).subquery()
user_package_ranks = db.session.query(all_package_ranks) \
.filter_by(author_id=user.id).first()
min_package_rank = user_package_ranks[1] if user_package_ranks else None

@ -218,7 +218,7 @@
</div>
</div>
{% endif %}
{% if min_package_rank <= 30 %}
{% if min_package_rank is not none and min_package_rank <= 30 %}
{% if min_package_rank <= 5 %}
{% set badge_color = "gold" %}
{% elif min_package_rank <= 10 %}