forked from rDrama/rDrama
1
0
Fork 0

add lifetime donated column

master
Aevann 2023-05-11 16:57:49 +03:00
parent b4ef8c53de
commit e3f58e3e78
4 changed files with 22 additions and 1 deletions

View File

@ -4,7 +4,7 @@ from typing import Union
import re import re
import pyotp import pyotp
from sqlalchemy import Column, ForeignKey from sqlalchemy import Column, ForeignKey, FetchedValue
from sqlalchemy.orm import aliased, deferred, Query from sqlalchemy.orm import aliased, deferred, Query
from sqlalchemy.sql import case, func, literal from sqlalchemy.sql import case, func, literal
from sqlalchemy.sql.expression import not_, and_, or_ from sqlalchemy.sql.expression import not_, and_, or_
@ -177,6 +177,8 @@ class User(Base):
sub_mods = relationship("Mod", primaryjoin="User.id == Mod.user_id", lazy="raise") sub_mods = relationship("Mod", primaryjoin="User.id == Mod.user_id", lazy="raise")
sub_exiles = relationship("Exile", primaryjoin="User.id == Exile.user_id", lazy="raise") sub_exiles = relationship("Exile", primaryjoin="User.id == Exile.user_id", lazy="raise")
lifetime_donated = deferred(Column(Integer, server_default=FetchedValue()))
def __init__(self, **kwargs): def __init__(self, **kwargs):
if "password" in kwargs: if "password" in kwargs:

View File

@ -7,6 +7,7 @@
<th>#</th> <th>#</th>
<th>Name</th> <th>Name</th>
<th>Tier</th> <th>Tier</th>
<th>Lifetime Donated</th>
<th>Truescore</th> <th>Truescore</th>
</tr> </tr>
</thead> </thead>
@ -19,6 +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=8"> <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=8">
{% endif %} {% endif %}
</td> </td>
<td>{{user.lifetime_donated}}</td>
<td>{{user.truescore}}</td> <td>{{user.truescore}}</td>
</tr> </tr>
{% endfor %} {% endfor %}

View File

@ -226,6 +226,11 @@
{% if u.is_private %} {% if u.is_private %}
<p id="profile--info--private">User has private mode enabled</p> <p id="profile--info--private">User has private mode enabled</p>
{% endif %} {% endif %}
{% if v and v.admin_level > PERMS['VIEW_PATRONS'] %}
<p id="profile--info--lifetime-donated">Lifetime Donated: ${{u.lifetime_donated}}</p>
{% endif %}
{% if v and (v.admin_level >= PERMS['VIEW_ALTS'] or v.alt) %} {% if v and (v.admin_level >= PERMS['VIEW_ALTS'] or v.alt) %}
{% if v.admin_level >= PERMS['USER_LINK'] %} {% if v.admin_level >= PERMS['USER_LINK'] %}
<span id="profile--alts"><a href="/@{{u.username}}/alts">{{alts|length}} Alt{{macros.plural(alts|length)}}</a>:</span> <span id="profile--alts"><a href="/@{{u.username}}/alts">{{alts|length}} Alt{{macros.plural(alts|length)}}</a>:</span>
@ -496,6 +501,11 @@
{% if u.is_private %} {% if u.is_private %}
<p id="profile-mobile--info--private">User has private mode enabled</p> <p id="profile-mobile--info--private">User has private mode enabled</p>
{% endif %} {% endif %}
{% if v and v.admin_level > PERMS['VIEW_PATRONS'] %}
<p id="profile-mobile--info--lifetime-donated">Lifetime Donated: ${{u.lifetime_donated}}</p>
{% endif %}
{% if v and (v.admin_level >= PERMS['VIEW_ALTS'] or v.alt) %} {% if v and (v.admin_level >= PERMS['VIEW_ALTS'] or v.alt) %}
{% if v.admin_level >= PERMS['USER_LINK'] %} {% if v.admin_level >= PERMS['USER_LINK'] %}
<span id="profile-mobile--alts"><a href="/@{{u.username}}/alts">{{alts|length}} Alt{{macros.plural(alts|length)}}</a>:</span> <span id="profile-mobile--alts"><a href="/@{{u.username}}/alts">{{alts|length}} Alt{{macros.plural(alts|length)}}</a>:</span>

View File

@ -0,0 +1,7 @@
create function public.lifetime_donated(public.users) returns integer
language sql immutable strict
as $_$
select sum(amount)
from transactions
where transactions.email = $1.email
$_$;