mirror of
https://github.com/SrIzan10/hc-harbor.git
synced 2026-05-01 10:45:21 +00:00
block convicted users from leaderboards
This commit is contained in:
@@ -44,6 +44,9 @@ class LeaderboardUpdateJob < ApplicationJob
|
||||
|
||||
entries_data = entries_data.filter { |_, total_seconds| total_seconds > 60 }
|
||||
|
||||
convicted_users = User.where(trust_level: User.trust_levels[:red]).pluck(:id)
|
||||
entries_data = entries_data.reject { |user_id, _| convicted_users.include?(user_id) }
|
||||
|
||||
streaks = Heartbeat.daily_streaks_for_users(entries_data.keys)
|
||||
|
||||
entries_data = entries_data.map do |user_id, total_seconds|
|
||||
|
||||
@@ -421,6 +421,10 @@ class User < ApplicationRecord
|
||||
"https://github.com/#{github_username}" if github_username.present?
|
||||
end
|
||||
|
||||
def self.not_convicted
|
||||
where.not(trust_level: User.trust_levels[:red])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def invalidate_activity_graph_cache
|
||||
|
||||
@@ -11,13 +11,13 @@ class LeaderboardGenerator
|
||||
|
||||
def generate_timezone_offset_leaderboard(date, utc_offset, period_type = :daily)
|
||||
date = Date.current if date.blank?
|
||||
users = User.users_in_timezone_offset(utc_offset)
|
||||
users = User.users_in_timezone_offset(utc_offset).not_convicted
|
||||
generate_leaderboard_for_users(users, date, "UTC#{utc_offset >= 0 ? '+' : ''}#{utc_offset}", period_type)
|
||||
end
|
||||
|
||||
def generate_timezone_leaderboard(date, timezone, period_type = :daily)
|
||||
date = Date.current if date.blank?
|
||||
users = User.users_in_timezone(timezone)
|
||||
users = User.users_in_timezone(timezone).not_convicted
|
||||
generate_leaderboard_for_users(users, date, timezone, period_type)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,20 @@
|
||||
<div class="container">
|
||||
<% if current_user&.trust_level == "red" %>
|
||||
<div class="acct-convicted">
|
||||
<strong>Hold up!</strong> Your account has been flagged for suspicious activity.<br> If this was a mistake, please <a href="https://hackclub.slack.com/team/U080A3QP42C">contact me on Slack</a> or email <a href="mailto:echo@hackclub.com">echo@hackclub.com</a>.
|
||||
</div>
|
||||
<style>
|
||||
.acct-convicted {
|
||||
color: #ff6467;
|
||||
background: color-mix(in oklab, rgb(251, 44, 54) 10%, transparent);
|
||||
border: 2px solid color-mix(in oklab, rgb(251, 44, 54) 20%, transparent);
|
||||
padding: 1em;
|
||||
text-align: center;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
</style>
|
||||
<% end %>
|
||||
<p class="super">
|
||||
<%= @flavor_text %>
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user