mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
Merge remote-tracking branch 'origin/main'
# Conflicts: # app/templates/admin/users.html
This commit is contained in:
commit
d27b6d8532
5 changed files with 15 additions and 13 deletions
|
@ -687,7 +687,7 @@ class User(UserMixin, db.Model):
|
|||
bounces = db.Column(db.SmallInteger, default=0)
|
||||
timezone = db.Column(db.String(20))
|
||||
reputation = db.Column(db.Float, default=0.0)
|
||||
attitude = db.Column(db.Float, default=1.0) # (upvotes cast - downvotes cast) / (upvotes + downvotes). A number between 1 and -1 is the ratio between up and down votes they cast
|
||||
attitude = db.Column(db.Float, default=None) # (upvotes cast - downvotes cast) / (upvotes + downvotes). A number between 1 and -1 is the ratio between up and down votes they cast
|
||||
post_count = db.Column(db.Integer, default=0)
|
||||
post_reply_count = db.Column(db.Integer, default=0)
|
||||
stripe_customer_id = db.Column(db.String(50))
|
||||
|
@ -934,13 +934,10 @@ class User(UserMixin, db.Model):
|
|||
total_upvotes = upvotes + comment_upvotes
|
||||
total_downvotes = downvotes + comment_downvotes
|
||||
|
||||
if total_downvotes == 0: # guard against division by zero
|
||||
self.attitude = 1.0
|
||||
else:
|
||||
if total_upvotes + total_downvotes > 2: # Only calculate attitude if they've done 3 or more votes as anything less than this could be an outlier and not representative of their overall attitude
|
||||
if total_upvotes + total_downvotes > 2: # Only calculate attitude if they've done 3 or more votes as anything less than this could be an outlier and not representative of their overall attitude (also guard against division by zero)
|
||||
self.attitude = (total_upvotes - total_downvotes) / (total_upvotes + total_downvotes)
|
||||
else:
|
||||
self.attitude = 1.0
|
||||
self.attitude = None
|
||||
|
||||
def recalculate_post_stats(self, posts=True, replies=True):
|
||||
if posts:
|
||||
|
|
|
@ -55,9 +55,9 @@
|
|||
</button>
|
||||
</th>
|
||||
<th>
|
||||
<button form="searchUsers" name="sort_by_btn" value="attitude{{' ASC' if sort_by == 'attitude DESC' else ' DESC' }}" class="btn" title="{{ _('Attitude: Percentage of up votes vs. down votes the account made.') }}">
|
||||
<button form="searchUsers" name="sort_by_btn" value="attitude{{' ASC' if sort_by == 'attitude DESC NULLS LAST' else ' DESC' }} NULLS LAST" class="btn" title="{{ _('Attitude: Percentage of up votes vs. down votes the account made.') }}">
|
||||
{{ _('Attitude') }}
|
||||
<span class="{{ 'fe fe-chevron-up' if sort_by == 'attitude ASC' }}{{ 'fe fe-chevron-down' if sort_by == 'attitude DESC' }}"></span>
|
||||
<span class="{{ 'fe fe-chevron-up' if sort_by == 'attitude ASC NULLS LAST' }}{{ 'fe fe-chevron-down' if sort_by == 'attitude DESC NULLS LAST' }}"></span>
|
||||
</button>
|
||||
</th>
|
||||
<th>
|
||||
|
@ -80,6 +80,11 @@
|
|||
<a href="/u/{{ user.link() }}">{{ user.user_name }}</a>{% if not user.is_local() %}<wbr />@<a href="{{ user.ap_profile_id }}">{{ user.ap_domain }}</a>{% endif %}</span></td>
|
||||
<td><span title="{{ _('Banned') }}">{{ '<span class="red">Banned</span>'|safe if user.banned }}
|
||||
{{ '<span class="red">Banned posts</span>'|safe if user.ban_posts }}
|
||||
{{ '<span class="red">Banned comments</span>'|safe if user.ban_comments }}</td>
|
||||
<td>{{ user.reports if user.reports > 0 }} </td>
|
||||
<td>{% if user.attitude %}{{ (user.attitude * 100) | round | int }}%{% endif %}</td>
|
||||
<td>{% if user.reputation %}R {{ user.reputation | round | int }}{% endif %}</td>
|
||||
<td><span title="{{ user.last_seen }}">{{ arrow.get(user.last_seen).humanize(locale=locale) }}</span></td>
|
||||
{{ '<span class="red">Banned comments</span>'|safe if user.ban_comments }}</span></td>
|
||||
<td><span title="{{ _('Reports') }}">{{ user.reports if user.reports > 0 }}</span></td>
|
||||
<td><span title="{{ _('Attitude') }}">{% if user.attitude != 1 %}{{ (user.attitude * 100) | round | int }}%{% endif %}</span></td>
|
||||
|
|
|
@ -116,7 +116,7 @@
|
|||
{% if user.bot %}
|
||||
{{ _('Bot Account') }}<br />
|
||||
{% endif %}
|
||||
{{ _('Attitude') }}: <span title="{{ _('Ratio of upvotes cast to downvotes cast. Higher is more positive.') }}">{{ (user.attitude * 100) | round | int }}%</span><br />
|
||||
{{ _('Attitude') }}: <span title="{{ _('Ratio of upvotes cast to downvotes cast. Higher is more positive.') }}">{% if user.attitude %}{{ (user.attitude * 100) | round | int }}%{% endif %}</span><br />
|
||||
{% if current_user.is_authenticated and current_user.is_admin() and user.reputation %}{{ _('Reputation') }}: <span title="{{ _('Reputation: The Karma of the account. Total up votes minus down votes they got.') }}">{{ user.reputation | round | int }}</span><br />{% endif %}
|
||||
{{ _('Posts') }}: {{ user.post_count }}<br />
|
||||
{{ _('Comments') }}: {{ user.post_reply_count }}<br />
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
{% if user.bot %}
|
||||
{{ _('Bot Account') }}<br />
|
||||
{% endif %}
|
||||
{{ _('Attitude') }}: <span title="{{ _('Ratio of upvotes cast to downvotes cast. Higher is more positive.') }}">{{ (user.attitude * 100) | round | int }}%</span><br />
|
||||
{{ _('Attitude') }}: <span title="{{ _('Ratio of upvotes cast to downvotes cast. Higher is more positive.') }}">{% if user.attitude %}{{ (user.attitude * 100) | round | int }}%{% endif %}</span><br />
|
||||
{% if current_user.is_authenticated and current_user.is_admin() and user.reputation %}{{ _('Reputation') }}: <span title="{{ _('Reputation: The Karma of the account. Total up votes minus down votes they got.') }}">{{ user.reputation | round | int }}</span><br />{% endif %}
|
||||
{{ _('Posts') }}: {{ user.post_count }}<br />
|
||||
{{ _('Comments') }}: {{ user.post_reply_count }}<br />
|
||||
|
|
|
@ -706,7 +706,7 @@ def can_downvote(user, community: Community, site=None) -> bool:
|
|||
if community.local_only and not user.is_local():
|
||||
return False
|
||||
|
||||
if user.attitude < -0.40 or user.reputation < -10: # this should exclude about 3.7% of users.
|
||||
if (user.attitude and user.attitude < -0.40) or user.reputation < -10: # this should exclude about 3.7% of users.
|
||||
return False
|
||||
|
||||
if community.id in communities_banned_from(user.id):
|
||||
|
|
Loading…
Reference in a new issue