From 46d1a5ad4b2700280c07ada99302fabba591c995 Mon Sep 17 00:00:00 2001 From: ntxtthomas Date: Fri, 12 Jun 2026 15:01:20 -0500 Subject: [PATCH 1/2] move poll to dashboard, refactor company eager_loads away to opportunities --- app/assets/stylesheets/application.css | 14 +++++++++++--- .../community_pulse_votes_controller.rb | 2 +- app/controllers/companies_controller.rb | 5 +---- app/controllers/dashboard_controller.rb | 8 ++++++++ app/controllers/opportunities_controller.rb | 2 +- app/views/dashboard/index.html.erb | 7 +++++++ app/views/devise/sessions/new.html.erb | 15 --------------- 7 files changed, 29 insertions(+), 24 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index ddc43d5..980cbce 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1496,6 +1496,11 @@ div[style*="color: red"], text-align: left; } +.dashboard-community-pulse-anchor { + margin-top: 2rem; + margin-bottom: 2rem; +} + .community-pulse-panel { border: 1px solid var(--border-color); border-radius: 0.75rem; @@ -1543,17 +1548,19 @@ div[style*="color: red"], .community-pulse-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 0.45rem; + gap: 0.4rem; } .community-pulse-option { border: 1px solid var(--border-color); - border-radius: 0.55rem; + border-radius: 0.48rem; background: var(--bg-secondary); color: var(--text-primary); - padding: 0.55rem 0.65rem; + padding: 0.48rem 0.57rem; font-size: 0.82rem; font-weight: 600; + width: 100%; + text-align: center; cursor: pointer; transition: background-color 0.15s ease, transform 0.15s ease; } @@ -1681,6 +1688,7 @@ div[style*="color: red"], .community-pulse-options { grid-template-columns: 1fr; + gap: 0.32rem; } .community-pulse-bar-row { diff --git a/app/controllers/community_pulse_votes_controller.rb b/app/controllers/community_pulse_votes_controller.rb index 8aa4754..9bef8a9 100644 --- a/app/controllers/community_pulse_votes_controller.rb +++ b/app/controllers/community_pulse_votes_controller.rb @@ -53,7 +53,7 @@ def create format.html do flash[:alert] = error_message if error_message.present? - redirect_to new_user_session_path(anchor: "community-pulse") + redirect_to dashboard_path(anchor: "community-pulse") end end end diff --git a/app/controllers/companies_controller.rb b/app/controllers/companies_controller.rb index 62df103..6808a0b 100644 --- a/app/controllers/companies_controller.rb +++ b/app/controllers/companies_controller.rb @@ -3,7 +3,7 @@ class CompaniesController < ApplicationController # GET /companies or /companies.json def index - @companies = current_or_demo_user.companies.includes(:opportunities) + @companies = current_or_demo_user.companies @technologies = Technology.order(:name) # Filter by company name search @@ -22,9 +22,6 @@ def index @selected_technology = params[:technology] end - # Always include technologies for display - @companies = @companies.includes(opportunities: :technologies) - # Skip sorting for tech_stack since it's aggregated data, but allow other columns if params[:sort].present? && params[:sort] != "tech_stack" direction = params[:direction] == "desc" ? "desc" : "asc" diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 0cbc398..8976f09 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -12,6 +12,14 @@ def index 0.0 end + pulse_vote_cookie = cookies.encrypted[:community_pulse_daily_votes] + pulse_daily_count = if pulse_vote_cookie.is_a?(Hash) && (pulse_vote_cookie["date"] || pulse_vote_cookie[:date]) == Date.current.iso8601 + (pulse_vote_cookie["count"] || pulse_vote_cookie[:count]).to_i + else + 0 + end + @pulse_votes_remaining = [ CommunityPulseVotesController::DAILY_LIMIT_MAX - pulse_daily_count, 0 ].max + # Role-based focus insights focus_analyzer = RoleFocusAnalyzer.new(opportunities) @focus_insights = focus_analyzer.generate_insights(limit: 4) diff --git a/app/controllers/opportunities_controller.rb b/app/controllers/opportunities_controller.rb index 898608c..77a9a06 100644 --- a/app/controllers/opportunities_controller.rb +++ b/app/controllers/opportunities_controller.rb @@ -3,7 +3,7 @@ class OpportunitiesController < ApplicationController # GET /opportunities or /opportunities.json def index - @opportunities = current_or_demo_user.opportunities.includes(:company, :technologies) + @opportunities = current_or_demo_user.opportunities.includes(:company, :technologies, :rich_text_other_tech_stack) if params[:company_query].present? company_query = "%#{params[:company_query].strip}%" diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index 8b2b073..39d96f3 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -180,3 +180,10 @@ <% end %> + +
+ <%= render "community_pulse_votes/panel", + votes_remaining: @pulse_votes_remaining, + daily_limit_reached: @pulse_votes_remaining.zero?, + error_message: nil %> +
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 6a37cea..0eb8064 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -33,20 +33,5 @@ <%= link_to "Continue as Guest", dashboard_path, class: "btn-guest" %>

Browse in read-only demo mode

- - <% pulse_vote_cookie = cookies.encrypted[:community_pulse_daily_votes] %> - <% pulse_daily_count = if pulse_vote_cookie.is_a?(Hash) && (pulse_vote_cookie["date"] || pulse_vote_cookie[:date]) == Date.current.iso8601 - (pulse_vote_cookie["count"] || pulse_vote_cookie[:count]).to_i - else - 0 - end %> - <% pulse_remaining = [CommunityPulseVotesController::DAILY_LIMIT_MAX - pulse_daily_count, 0].max %> - -
- <%= render "community_pulse_votes/panel", - votes_remaining: pulse_remaining, - daily_limit_reached: pulse_remaining.zero?, - error_message: nil %> -
From 618afc3e7d0ae2cb9b5da00c32a3905985eb5a96 Mon Sep 17 00:00:00 2001 From: ntxtthomas Date: Fri, 12 Jun 2026 15:14:10 -0500 Subject: [PATCH 2/2] updated_tests for new path --- spec/requests/community_pulse_votes_spec.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spec/requests/community_pulse_votes_spec.rb b/spec/requests/community_pulse_votes_spec.rb index 5ddab03..1e5195e 100644 --- a/spec/requests/community_pulse_votes_spec.rb +++ b/spec/requests/community_pulse_votes_spec.rb @@ -22,7 +22,7 @@ params: { community_pulse_vote: { topic: "getting_interviews" } } end.to change(CommunityPulseVote, :count).by(1) - expect(response).to redirect_to(new_user_session_path(anchor: "community-pulse")) + expect(response).to redirect_to(dashboard_path(anchor: "community-pulse")) expect(response.headers["Set-Cookie"]).to include("community_pulse_daily_votes") end @@ -35,7 +35,7 @@ params: { community_pulse_vote: { topic: "passing_screens" } } end.to change(CommunityPulseVote, :count).by(1) - expect(response).to redirect_to(new_user_session_path(anchor: "community-pulse")) + expect(response).to redirect_to(dashboard_path(anchor: "community-pulse")) end it "blocks the sixth vote in the same day for the same connection" do @@ -44,7 +44,7 @@ params: { community_pulse_vote: { topic: "getting_interviews" } }, headers: { "HTTP_USER_AGENT" => "DailyLimitSpec/1", "REMOTE_ADDR" => "203.0.113.10" } - expect(response).to redirect_to(new_user_session_path(anchor: "community-pulse")) + expect(response).to redirect_to(dashboard_path(anchor: "community-pulse")) end travel_to(Time.current + 11.minutes) do @@ -55,9 +55,8 @@ end.not_to change(CommunityPulseVote, :count) end - expect(response).to redirect_to(new_user_session_path(anchor: "community-pulse")) - follow_redirect! - expect(response.body).to include("You have reached today's vote limit") + expect(response).to redirect_to(dashboard_path(anchor: "community-pulse")) + expect(flash[:alert]).to eq("You have reached today's vote limit. Please come back tomorrow.") end it "rate limits burst submissions from the same connection" do