default result sorting to quiz submission descending

completes #85
This commit is contained in:
Mark Moser 2016-12-04 16:41:07 -06:00
parent 73df3d1258
commit 9cf2aeb139
6 changed files with 28 additions and 7 deletions

View File

@ -10,7 +10,9 @@ module Admin
# TODO: Limit results to the quizzes current_user has access to
def index
@candidates = Candidate.where(completed: true).includes(:recruiter)
@candidates = Candidate.where(completed: true)
.includes(:recruiter)
.order(:review_status, completed_at: :desc)
end
def view

View File

@ -35,7 +35,7 @@ class QuizController < ApplicationController
private
def complete_and_email
if current_candidate.update_attributes(completed: true)
if current_candidate.update_attributes(completed: true, completed_at: DateTime.current)
current_candidate.build_reviews
CandidateMailer.submitted(current_candidate).deliver_later
RecruiterMailer.candidate_submitted(current_candidate).deliver_later

View File

@ -8,6 +8,7 @@
<th>Test ID</th>
<th>Experience</th>
<th>Recruiter</th>
<th>Submitted on</th>
<th>Interview?</th>
</tr>
@ -16,6 +17,7 @@
<td><%= link_to candidate.test_hash, admin_result_path(candidate.test_hash) %></td>
<td><%= candidate.experience %> years</td>
<td><%= mail_to(candidate.recruiter.email) %></td>
<td><%= candidate.completed_at.strftime('%D') unless candidate.completed_at.nil? %></td>
<td><%= candidate.interview? %></td>
</tr>
<% end %>

View File

@ -0,0 +1,12 @@
# frozen_string_literal: true
class AddCompletedAt < ActiveRecord::Migration[5.0]
def change
add_column :candidates, :completed_at, :datetime, after: :completed
Candidate.reset_column_information
Candidate.where(completed: true).each do |candidate|
candidate.completed_at = candidate.updated_at
candidate.save
end
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20161120175737) do
ActiveRecord::Schema.define(version: 20161204220527) do
create_table "answers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.integer "candidate_id"
@ -32,6 +32,7 @@ ActiveRecord::Schema.define(version: 20161120175737) do
t.string "experience"
t.integer "recruiter_id"
t.boolean "completed"
t.datetime "completed_at"
t.boolean "reminded"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false

View File

@ -57,6 +57,7 @@ richard: # Richard has completed AND submitted the test
recruiter: recruiter
quiz: fed
completed: true
completed_at: <%= DateTime.current %>
reminded: false
test_hash: 6NjnourLE6Y
review_status: 1
@ -78,6 +79,7 @@ stacy: # Stacy has completed AND submitted the test
recruiter: recruiter
quiz: fed
completed: true
completed_at: <%= DateTime.current %>
reminded: false
test_hash: s6oFExZliYYFx
review_status: 2
@ -89,6 +91,7 @@ henry: # Henry has completed AND submitted the test
recruiter: recruiter
quiz: fed
completed: true
completed_at: <%= DateTime.current %>
reminded: false
test_hash: egPomAuVDeCEp
@ -99,6 +102,7 @@ wade: # Wade has completed AND submitted the test
recruiter: recruiter
quiz: fed
completed: true
completed_at: <%= DateTime.current %>
reminded: false
test_hash: BkSkpapJnkz2N