From e4edc42ffeb2f67851bc922c440f903eab187cb7 Mon Sep 17 00:00:00 2001 From: ntxtthomas Date: Thu, 18 Jun 2026 09:21:26 -0500 Subject: [PATCH 1/4] update interview equation on widget --- app/controllers/dashboard_controller.rb | 6 +- app/views/dashboard/index.html.erb | 2 +- spec/requests/dashboard_spec.rb | 86 +++++++++++++++++++ test/controllers/dashboard_controller_test.rb | 8 -- 4 files changed, 91 insertions(+), 11 deletions(-) create mode 100644 spec/requests/dashboard_spec.rb delete mode 100644 test/controllers/dashboard_controller_test.rb diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 8976f09..96aa74f 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,11 +1,13 @@ class DashboardController < ApplicationController def index opportunities = current_or_demo_user.opportunities + submitted_opportunities = opportunities.where.not(application_date: nil) - @total_resumes = opportunities.where.not(application_date: nil).count + @total_resumes = submitted_opportunities.count @total_open_applications = opportunities.where(status: %w[applied interviewing]).count @total_assessed = opportunities.count - @total_interviews = InterviewSession.where(opportunity_id: opportunities.select(:id)).count + # Count interview processes, not interview rounds: 1 per submitted opportunity that has interviews. + @total_interviews = submitted_opportunities.joins(:interview_sessions).distinct.count @interview_conversion_rate = if @total_resumes.positive? ((@total_interviews.to_f / @total_resumes) * 100).round(1) else diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index 39d96f3..1fd4860 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -26,7 +26,7 @@
-

Total Interviews

+

Companies That Interviewed Me

<%= @total_interviews %>
diff --git a/spec/requests/dashboard_spec.rb b/spec/requests/dashboard_spec.rb new file mode 100644 index 0000000..8f422a0 --- /dev/null +++ b/spec/requests/dashboard_spec.rb @@ -0,0 +1,86 @@ +require "rails_helper" + +RSpec.describe "Dashboard", type: :request do + let(:user) { create(:user) } + + before { sign_in user } + + let!(:company) do + Company.create!( + name: "Metrics Co", + industry: "Technology", + location: "Remote", + website: "https://metrics.example", + company_type: "Product", + user: user + ) + end + + describe "GET /dashboard" do + it "counts one interview process per submitted application and calculates conversion correctly" do + submitted_with_many_rounds = Opportunity.create!( + company: company, + position_title: "Platform Engineer", + role_type: "software_engineer", + status: "interviewing", + application_date: Date.current - 3.days + ) + + submitted_with_one_round = Opportunity.create!( + company: company, + position_title: "Senior Backend Engineer", + role_type: "software_engineer", + status: "interviewing", + application_date: Date.current - 2.days + ) + + submitted_without_interviews = Opportunity.create!( + company: company, + position_title: "Ruby Engineer", + role_type: "software_engineer", + status: "applied", + application_date: Date.current - 1.day + ) + + not_submitted_with_interviews = Opportunity.create!( + company: company, + position_title: "Staff Engineer", + role_type: "software_engineer", + status: "assessed" + ) + + %w[recruiter technical final].each do |stage| + InterviewSession.create!( + opportunity: submitted_with_many_rounds, + stage: stage, + scheduled_at: Time.current, + format: "video", + status: "completed" + ) + end + + InterviewSession.create!( + opportunity: submitted_with_one_round, + stage: "recruiter", + scheduled_at: Time.current, + format: "phone", + status: "completed" + ) + + InterviewSession.create!( + opportunity: not_submitted_with_interviews, + stage: "recruiter", + scheduled_at: Time.current, + format: "phone", + status: "completed" + ) + + get dashboard_path + + expect(response).to have_http_status(:ok) + expect(response.body).to include("Companies That Interviewed Me") + expect(response.body).to match(/Companies That Interviewed Me.*?
2<\/div>/m) + expect(response.body).to include("66.7% of applications submitted") + end + end +end diff --git a/test/controllers/dashboard_controller_test.rb b/test/controllers/dashboard_controller_test.rb deleted file mode 100644 index a46443c..0000000 --- a/test/controllers/dashboard_controller_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "test_helper" - -class DashboardControllerTest < ActionDispatch::IntegrationTest - test "should get index" do - get dashboard_url - assert_response :success - end -end From 085aced2e1fe96ad6a9b2c6da73389cab664dd9d Mon Sep 17 00:00:00 2001 From: ntxtthomas Date: Thu, 18 Jun 2026 09:35:34 -0500 Subject: [PATCH 2/4] update brakeman --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 1fbf1e1..0f3b34e 100644 --- a/Gemfile +++ b/Gemfile @@ -72,7 +72,7 @@ group :development, :test do gem "pry-rails" # Static analysis for security vulnerabilities [https://brakemanscanner.org/] - gem "brakeman", "~> 8.0.4", require: false + gem "brakeman", ">= 8.0.4", require: false # Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/] gem "rubocop-rails-omakase", require: false From 27d0eee0d352dbeae2988713dadd02377c8a9463 Mon Sep 17 00:00:00 2001 From: ntxtthomas Date: Thu, 18 Jun 2026 09:57:36 -0500 Subject: [PATCH 3/4] bundled --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 91a8157..7f4b073 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -446,7 +446,7 @@ PLATFORMS DEPENDENCIES appsignal (~> 4.8, >= 4.8.4) bootsnap - brakeman (~> 8.0.4) + brakeman (>= 8.0.4) bullet (~> 8.1, >= 8.1.1) capybara csv From 3e940087f125a67ebbdbe4767111097eb93e05fc Mon Sep 17 00:00:00 2001 From: ntxtthomas Date: Thu, 18 Jun 2026 10:26:40 -0500 Subject: [PATCH 4/4] bundled lockfile --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7f4b073..bd9e366 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,7 +86,7 @@ GEM bindex (0.8.1) bootsnap (1.18.6) msgpack (~> 1.2) - brakeman (8.0.4) + brakeman (8.0.5) racc builder (3.3.0) bullet (8.1.1)