diff --git a/app/views/leaderboards/index.html.erb b/app/views/leaderboards/index.html.erb index 5a1c9ac..00eccb7 100644 --- a/app/views/leaderboards/index.html.erb +++ b/app/views/leaderboards/index.html.erb @@ -1,16 +1,28 @@
-

Today's Leaderboard

+

Leaderboard

+ +
+ <%= link_to "Daily", leaderboards_path(period_type: 'daily'), + class: "period-toggle-btn #{@period_type == :daily ? 'active' : ''}" %> + <%= link_to "Weekly", leaderboards_path(period_type: 'weekly'), + class: "period-toggle-btn #{@period_type == :weekly ? 'active' : ''}" %> +
+

- <%= Date.current.strftime("%B %d, %Y") %> - <% unless @leaderboard.nil? %> + <% if @leaderboard %> + <%= @leaderboard.date_range_text %> Updated <%= time_ago_in_words(@leaderboard.updated_at) %> ago + <% else %> + <%= @period_type == :weekly ? + "#{Date.current.beginning_of_week.strftime('%B %d')} - #{(Date.current.beginning_of_week + 6.days).strftime('%B %d, %Y')}" : + Date.current.strftime("%B %d, %Y") %> <% end %>

- <% if @entries.any? %> + <% if @entries&.any? %> @@ -40,8 +52,8 @@ <% else %>

No data available

-

Check back later for today's results!

+

Check back later for <%= @period_type == :weekly ? "this week's" : "today's" %> results!

<% end %> - \ No newline at end of file + \ No newline at end of file diff --git a/config/initializers/good_job.rb b/config/initializers/good_job.rb index 02d8b6a..f71dc9d 100644 --- a/config/initializers/good_job.rb +++ b/config/initializers/good_job.rb @@ -8,9 +8,15 @@ Rails.application.configure do cron: "*/5 * * * *", class: "UserSlackStatusUpdateJob" }, - leaderboard_update: { - cron: "*/5 * * * *", - class: "LeaderboardUpdateJob" + daily_leaderboard_update: { + cron: "0 0 * * *", + class: "LeaderboardUpdateJob", + args: [-> { Date.current.to_s }, "daily"] + }, + weekly_leaderboard_update: { + cron: "0 0 * * 1", + class: "LeaderboardUpdateJob", + args: [-> { Date.current.beginning_of_week.to_s }, "weekly"] }, sailors_log_poll: { cron: "* * * * *", @@ -21,4 +27,4 @@ Rails.application.configure do class: "SlackCommand::UpdateSlackChannelCacheJob" } } -end +end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index dba770d..552a4bf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -170,6 +170,13 @@ ActiveRecord::Schema[8.0].define(version: 2025_03_13_205725) do t.datetime "updated_at", null: false t.datetime "finished_generating_at" t.datetime "deleted_at" + t.integer "period_type", default: 0, null: false + end + + create_table "project_labels", id: :serial, force: :cascade do |t| + t.text "user_id" + t.text "project_key" + t.text "label" end create_table "project_repo_mappings", force: :cascade do |t|