forked from MarseyWorld/MarseyWorld
fix top 10 patrons badge
parent
164de9e966
commit
69ec9dab2f
|
@ -158,6 +158,7 @@ class User(Base):
|
|||
marsify = Column(Integer, default=0)
|
||||
rainbow = Column(Integer, default=0)
|
||||
spider = Column(Integer, default=0)
|
||||
lifetimedonated = Column(Integer, default=0)
|
||||
blacklisted_by = Column(Integer, ForeignKey("users.id"))
|
||||
|
||||
if IS_FISTMAS():
|
||||
|
@ -180,8 +181,6 @@ class User(Base):
|
|||
sub_mods = relationship("Mod", primaryjoin="User.id == Mod.user_id", lazy="raise")
|
||||
sub_exiles = relationship("Exile", primaryjoin="User.id == Exile.user_id", lazy="raise")
|
||||
|
||||
lifetimedonated = deferred(Column(Integer, server_default=FetchedValue()))
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
||||
if "password" in kwargs:
|
||||
|
@ -253,11 +252,6 @@ class User(Base):
|
|||
|
||||
return (succeeded, charged_coins)
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def lifetime_donated(self):
|
||||
return self.lifetimedonated or 0
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def num_of_bought_awards(self):
|
||||
|
|
|
@ -81,25 +81,27 @@ def claim_rewards_all_users():
|
|||
for x in range(22, badge_id+1):
|
||||
badge_grant(badge_id=x, user=user)
|
||||
|
||||
if user.lifetime_donated >= 100:
|
||||
user.lifetimedonated = g.db.query(func.sum(Transaction.amount)).filter_by(email=user.email).scalar()
|
||||
|
||||
if user.lifetimedonated >= 100:
|
||||
badge_grant(badge_id=257, user=user)
|
||||
|
||||
if user.lifetime_donated >= 500:
|
||||
if user.lifetimedonated >= 500:
|
||||
badge_grant(badge_id=258, user=user)
|
||||
|
||||
if user.lifetime_donated >= 2500:
|
||||
if user.lifetimedonated >= 2500:
|
||||
badge_grant(badge_id=259, user=user)
|
||||
|
||||
if user.lifetime_donated >= 5000:
|
||||
if user.lifetimedonated >= 5000:
|
||||
badge_grant(badge_id=260, user=user)
|
||||
|
||||
if user.lifetime_donated >= 10000:
|
||||
if user.lifetimedonated >= 10000:
|
||||
badge_grant(badge_id=261, user=user)
|
||||
|
||||
print(f'@{user.username} rewards claimed successfully!', flush=True)
|
||||
|
||||
# for user in g.db.query(User).options(load_only(User.id)).order_by(User.lifetimedonated.desc()).limit(10).all():
|
||||
# badge_grant(badge_id=294, user=user)
|
||||
for user in g.db.query(User).options(load_only(User.id)).order_by(User.lifetimedonated.desc()).limit(10).all():
|
||||
badge_grant(badge_id=294, user=user)
|
||||
|
||||
def transfer_currency(v, username, currency_name, apply_tax):
|
||||
MIN_CURRENCY_TRANSFER = 100
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<img class="contain" alt="2{{user.patron}}" loading="lazy" width=29.33 height=32 src="{{SITE_FULL_IMAGES}}/i/{{SITE_NAME}}/badges/2{{user.patron}}.webp?b=10" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{user.patron_tooltip}}">
|
||||
{% endif %}
|
||||
</td>
|
||||
<td data-sort-key="{{user.lifetime_donated}}">${{user.lifetime_donated}}</td>
|
||||
<td data-sort-key="{{user.lifetimedonated}}">${{user.lifetimedonated}}</td>
|
||||
<td>{{user.truescore}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -234,7 +234,7 @@
|
|||
<p id="profile--info--spent">Coins spent on hats: {{u.coins_spent_on_hats}}</p>
|
||||
|
||||
{% if v and (v.id == u.id or v.admin_level >= PERMS['VIEW_PATRONS']) %}
|
||||
<p id="profile--info--lifetime-donated">Lifetime donated: ${{u.lifetime_donated}} (shown to you only)</p>
|
||||
<p id="profile--info--lifetime-donated">Lifetime donated: ${{u.lifetimedonated}} (shown to you only)</p>
|
||||
{% endif %}
|
||||
|
||||
<p id="profile--info--discount">Total award discount: {{u.formatted_discount}}</p>
|
||||
|
@ -512,7 +512,7 @@
|
|||
<p id="profile-mobile--info--spent">Coins spent on hats: {{u.coins_spent_on_hats}}</p>
|
||||
|
||||
{% if v and (v.id == u.id or v.admin_level >= PERMS['VIEW_PATRONS']) %}
|
||||
<p id="profile-mobile--info--lifetime-donated">Lifetime donated: ${{u.lifetime_donated}} (shown to you only)</p>
|
||||
<p id="profile-mobile--info--lifetime-donated">Lifetime donated: ${{u.lifetimedonated}} (shown to you only)</p>
|
||||
{% endif %}
|
||||
|
||||
<p id="profile-mobile--info--discount">Total award discount: {{u.formatted_discount}}</p>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
alter table users add column lifetimedonated int not null default 0;
|
||||
alter table users alter column lifetimedonated drop default;
|
||||
update users set lifetimedonated=(select sum(amount) from transactions where transactions.email = users.email) where (select sum(amount) from transactions where transactions.email = users.email)>0;
|
Loading…
Reference in New Issue