Only show untracked warning if user isn't on leaderboard

This commit is contained in:
Max Wofford 2025-03-11 21:31:11 -04:00
parent 89d5ddeba7
commit f5fad7ae49
2 changed files with 17 additions and 12 deletions

View file

@ -12,12 +12,15 @@ class LeaderboardsController < ApplicationController
tracked_user_ids = @leaderboard.entries.distinct.pluck(:slack_uid)
today = Time.current
@untracked_entries = Hackatime::Heartbeat
.where(time: today.beginning_of_day..today.end_of_day)
.distinct
.pluck(:user_id)
.count { |user_id| !tracked_user_ids.include?(user_id) }
@user_on_leaderboard = current_user && tracked_user_ids.include?(current_user.slack_uid)
unless @user_on_leaderboard
today = Time.current
@untracked_entries = Hackatime::Heartbeat
.where(time: today.beginning_of_day..today.end_of_day)
.distinct
.pluck(:user_id)
.count { |user_id| !tracked_user_ids.include?(user_id) }
end
end
end
end

View file

@ -29,12 +29,14 @@
<% end %>
</tbody>
</table>
<p>
Don't see yourself on the leaderboard? You're probably one of the
<%= pluralize(@untracked_entries, "user") %>
who haven't
<%= link_to "updated their wakatime config", my_settings_path, target: "_blank" %>.
</p>
<% unless @user_on_leaderboard %>
<p>
Don't see yourself on the leaderboard? You're probably one of the
<%= pluralize(@untracked_entries, "user") %>
who haven't
<%= link_to "updated their wakatime config", my_settings_path, target: "_blank" %>.
</p>
<% end %>
<% else %>
<div class="empty-state">
<h3>No data available</h3>