diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 468e0ff05..eb4912def 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -16,9 +16,6 @@ def index if !current_user.heartbeats.exists? || params[:show_wakatime_setup_notice] @show_wakatime_setup_notice = true - if (ssp = Cache::SetupSocialProofJob.perform_now) - @ssp_message, @ssp_users_recent, @ssp_users_size = ssp.values_at(:message, :users_recent, :users_size) - end end render inertia: "Home/SignedIn", props: signed_in_props @@ -26,8 +23,6 @@ def index # Set homepage SEO content for logged-out users only set_homepage_seo_content - @usage_social_proof = Cache::UsageSocialProofJob.perform_now - @home_stats = Cache::HomeStatsJob.perform_now render inertia: "Home/SignedOut", props: signed_out_props @@ -137,9 +132,6 @@ def signed_in_props flavor_text: @flavor_text.to_s, trust_level_red: current_user&.trust_level == "red", show_wakatime_setup_notice: !!@show_wakatime_setup_notice, - ssp_message: @ssp_message, - ssp_users_recent: @ssp_users_recent || [], - ssp_users_size: @ssp_users_size || @ssp_users_recent&.size || 0, github_uid_blank: current_user&.github_uid.blank?, dashboard_stats: dashboard_stats || InertiaRails.defer { dashboard_stats_payload } } diff --git a/app/javascript/pages/Home/SignedIn.svelte b/app/javascript/pages/Home/SignedIn.svelte index 9a9b7bdba..2875cb287 100644 --- a/app/javascript/pages/Home/SignedIn.svelte +++ b/app/javascript/pages/Home/SignedIn.svelte @@ -2,7 +2,6 @@ import { Deferred, router } from "@inertiajs/svelte"; import type { ActivityGraphData, - SocialProofUser, FilterableDashboardData, TodayStats, ProgrammingGoalProgress, @@ -21,18 +20,12 @@ flavor_text, trust_level_red, show_wakatime_setup_notice, - ssp_message, - ssp_users_recent, - ssp_users_size, github_uid_blank, dashboard_stats, }: { flavor_text: string; trust_level_red: boolean; show_wakatime_setup_notice: boolean; - ssp_message?: string | null; - ssp_users_recent: SocialProofUser[]; - ssp_users_size: number; github_uid_blank: boolean; dashboard_stats?: { filterable_dashboard_data: FilterableDashboardData; @@ -78,7 +71,7 @@ {/if} {#if show_wakatime_setup_notice} - + {:else if github_uid_blank} {/if} diff --git a/app/javascript/pages/Home/signedIn/SetupNotice.svelte b/app/javascript/pages/Home/signedIn/SetupNotice.svelte index bdac53bd9..4e0e5b9b8 100644 --- a/app/javascript/pages/Home/signedIn/SetupNotice.svelte +++ b/app/javascript/pages/Home/signedIn/SetupNotice.svelte @@ -1,20 +1,7 @@ @@ -37,9 +24,4 @@ > - diff --git a/app/javascript/pages/Home/signedIn/SocialProofUsers.svelte b/app/javascript/pages/Home/signedIn/SocialProofUsers.svelte deleted file mode 100644 index 3b9726991..000000000 --- a/app/javascript/pages/Home/signedIn/SocialProofUsers.svelte +++ /dev/null @@ -1,82 +0,0 @@ - - -
- {#if users.length > 0} -
- {#each users as user, index} -
0 ? "-ml-4" : ""}`} - > - - {user.display_name} -
- {/each} - {#if total_size > 5} -
-
- +{total_size - 5} -
- -
- {/if} -
- {/if} - {#if message} -

- {message} (this is real data) -

- {/if} -
diff --git a/app/javascript/types/index.ts b/app/javascript/types/index.ts index be9d4291f..1e032bddc 100644 --- a/app/javascript/types/index.ts +++ b/app/javascript/types/index.ts @@ -142,8 +142,6 @@ export type ProjectStats = { activity_graph: ActivityGraphData; }; -export type SocialProofUser = { display_name: string; avatar_url: string }; - export type FilterableDashboardData = { total_time: number; total_heartbeats: number; diff --git a/app/jobs/cache/setup_social_proof_job.rb b/app/jobs/cache/setup_social_proof_job.rb deleted file mode 100644 index 34c88bbe1..000000000 --- a/app/jobs/cache/setup_social_proof_job.rb +++ /dev/null @@ -1,43 +0,0 @@ -class Cache::SetupSocialProofJob < Cache::ActivityJob - queue_as :latency_10s - - private - - def calculate - # Only run queries as needed, starting with the smallest time range - check_social_proof(5.minutes, 1, "in the last 5 minutes") || - check_social_proof(1.hour, 3, "in the last hour") || - check_social_proof(1.day, 5, "today") || - check_social_proof(1.week, 5, "in the past week") || - check_social_proof(1.month, 5, "in the past month") || - check_social_proof(1.year, 5, "in the past year") - end - - def check_social_proof(time_period, threshold, humanized_time_period) - user_ids = Heartbeat.where("time > ?", time_period.ago.to_f) - .where("time < ?", Time.current.to_f) - .with_valid_timestamps - .where(source_type: :test_entry) - .distinct - .pluck(:user_id) - - user_count = user_ids.size - return nil if user_count < threshold - - recent_setup_users = User.where(id: user_ids).limit(5).map do |user| - { - id: user.id, - avatar_url: user.avatar_url, - display_name: user.display_name || "Hack Clubber" - } - end - - message = "#{user_count.to_s + ' Hack Clubber'.pluralize(user_count)} set up Hackatime #{humanized_time_period}" - - { - message: message, - users_size: user_count, - users_recent: recent_setup_users - } - end -end diff --git a/app/jobs/cache/usage_social_proof_job.rb b/app/jobs/cache/usage_social_proof_job.rb deleted file mode 100644 index 949e698f9..000000000 --- a/app/jobs/cache/usage_social_proof_job.rb +++ /dev/null @@ -1,23 +0,0 @@ -class Cache::UsageSocialProofJob < Cache::ActivityJob - queue_as :latency_10s - - private - - def calculate - # Only run queries as needed, starting with the smallest time range - if (past_hour_count = users_in_past(1.hour)) > 5 - "In the past hour, #{past_hour_count} Hack Clubbers have coded with Hackatime." - elsif (past_day_count = users_in_past(1.day)) > 5 - "In the past day, #{past_day_count} Hack Clubbers have coded with Hackatime." - elsif (past_week_count = users_in_past(1.week)) > 5 - "In the past week, #{past_week_count} Hack Clubbers have coded with Hackatime." - end - end - - def users_in_past(duration) - Heartbeat.coding_only - .with_valid_timestamps - .where("time > ?", duration.ago.to_f) - .distinct.count(:user_id) - end -end diff --git a/config/initializers/good_job.rb b/config/initializers/good_job.rb index 4fa191621..8c7fc2d62 100644 --- a/config/initializers/good_job.rb +++ b/config/initializers/good_job.rb @@ -90,16 +90,6 @@ class: "Cache::ActiveProjectsJob", kwargs: { force_reload: true } }, - cache_usage_social_proof: { - cron: "* * * * *", - class: "Cache::UsageSocialProofJob", - kwargs: { force_reload: true } - }, - cache_setup_social_proof: { - cron: "* * * * *", - class: "Cache::SetupSocialProofJob", - kwargs: { force_reload: true } - }, cache_minutes_logged: { cron: "* * * * *", class: "Cache::MinutesLoggedJob", diff --git a/lib/tasks/cache.rake b/lib/tasks/cache.rake index 482209785..40679a232 100644 --- a/lib/tasks/cache.rake +++ b/lib/tasks/cache.rake @@ -9,9 +9,7 @@ namespace :cache do Cache::HomeStatsJob, Cache::HeartbeatCountsJob, Cache::ActiveProjectsJob, - Cache::MinutesLoggedJob, - Cache::SetupSocialProofJob, - Cache::UsageSocialProofJob + Cache::MinutesLoggedJob ] cache_jobs.each do |job_class|