diff --git a/app/admin/routes.py b/app/admin/routes.py index 614a117f..e3f5d9b2 100644 --- a/app/admin/routes.py +++ b/app/admin/routes.py @@ -533,16 +533,18 @@ def admin_users_trash(): users = users.filter(User.email.ilike(f"%{search}%")) if type == '' or type == 'bad_rep': + users = users.filter(User.last_seen > utcnow() - timedelta(days=7)) users = users.filter(User.reputation < -10) users = users.order_by(User.reputation).paginate(page=page, per_page=1000, error_out=False) elif type == 'bad_attitude': + users = users.filter(User.last_seen > utcnow() - timedelta(days=7)) users = users.filter(User.attitude < 0.0) users = users.order_by(User.attitude).paginate(page=page, per_page=1000, error_out=False) next_url = url_for('admin.admin_users_trash', page=users.next_num, search=search, local_remote=local_remote, type=type) if users.has_next else None prev_url = url_for('admin.admin_users_trash', page=users.prev_num, search=search, local_remote=local_remote, type=type) if users.has_prev and page != 1 else None - return render_template('admin/users.html', title=_('Problematic users'), next_url=next_url, prev_url=prev_url, users=users, + return render_template('admin/users_trash.html', title=_('Problematic users'), next_url=next_url, prev_url=prev_url, users=users, local_remote=local_remote, search=search, type=type, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), diff --git a/app/models.py b/app/models.py index 625beca1..59906c2e 100644 --- a/app/models.py +++ b/app/models.py @@ -808,7 +808,10 @@ class User(UserMixin, db.Model): if total_downvotes == 0: # guard against division by zero self.attitude = 1.0 else: - self.attitude = (total_upvotes - total_downvotes) / (total_upvotes + total_downvotes) + 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 + self.attitude = (total_upvotes - total_downvotes) / (total_upvotes + total_downvotes) + else: + self.attitude = 1.0 def subscribed(self, community_id: int) -> int: if community_id is None: diff --git a/app/templates/admin/users.html b/app/templates/admin/users.html index e34961c2..3283f80d 100644 --- a/app/templates/admin/users.html +++ b/app/templates/admin/users.html @@ -15,8 +15,6 @@ - -
Name | +Local/Remote | +Seen | +Attitude | +Rep | +Banned | +Reports | +IP | +Source | +Actions | +
---|---|---|---|---|---|---|---|---|---|
+ {{ user.display_name() }} | +{{ 'Local' if user.is_local() else 'Remote' }} | +{% if request.args.get('local_remote', '') == 'local' %} + {{ moment(user.last_seen).fromNow() }} + {% else %} + {{ user.last_seen }} + {% endif %} + | +{{ user.attitude * 100 if user.attitude != 1 }} | +{{ 'R ' + str(user.reputation) if user.reputation }} | +{{ 'Banned'|safe if user.banned }} | +{{ user.reports if user.reports > 0 }} | +{{ user.ip_address if user.ip_address }} | +{{ user.referrer if user.referrer }} | +View local | + {% if not user.is_local() %} + View remote | + {% else %} + View remote | + {% endif %} + Edit | + Delete + | +