diff --git a/app/controllers/leaderboards_controller.rb b/app/controllers/leaderboards_controller.rb index 41a0766..a520b9a 100644 --- a/app/controllers/leaderboards_controller.rb +++ b/app/controllers/leaderboards_controller.rb @@ -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 diff --git a/app/views/leaderboards/index.html.erb b/app/views/leaderboards/index.html.erb index 444c650..1bc399a 100644 --- a/app/views/leaderboards/index.html.erb +++ b/app/views/leaderboards/index.html.erb @@ -29,12 +29,14 @@ <% end %> -

- 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" %>. -

+ <% unless @user_on_leaderboard %> +

+ 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" %>. +

+ <% end %> <% else %>

No data available