Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/dashboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<div class="card funnel-card card-interviews">
<div class="card-header justify-center text-center">
<h3>Total Interviews</h3>
<h3>Companies That Interviewed Me</h3>
</div>
<div class="card-body">
<div class="card-number"><%= @total_interviews %></div>
Expand Down
86 changes: 86 additions & 0 deletions spec/requests/dashboard_spec.rb
Original file line number Diff line number Diff line change
@@ -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.*?<div class=\"card-number\">2<\/div>/m)
expect(response.body).to include("66.7% of applications submitted")
end
end
end
8 changes: 0 additions & 8 deletions test/controllers/dashboard_controller_test.rb

This file was deleted.

Loading