Class AdminsController
has 21 methods (exceeds 20 allowed). Consider refactoring.
class AdminsController < ApplicationController
layout 'admin_layout', :only => [:home, :update_semester, :updateCurrentSemester, :rating_tutors, :tutor_hours, :update_password, :update_student_priorities, :manage_tutors, :manage_semester, :update_question_templates]
before_action :set_admin, except: [:landing, :destroyAdminSession]
before_action :check_logged_in, except: [:landing, :createAdminSession, :destroyAdminSession]
Method batch_update
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
def batch_update
new_ordering = []
params.keys.each do |k|
if k.include?('qt')
Method set_tutor
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def set_tutor
if params[:id] == "sign_out" || params[:id] == "new"
redirect_to new_tutor_session_path
elsif params[:id] == "password"
redirect_to new_tutor_password_path
Method check_valid_tutee
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def check_valid_tutee
if ['tutees','tutees/registrations'].include? params[:controller] and current_tutee&.id.to_i == params[:id].to_i
Similar blocks of code found in 2 locations. Consider refactoring.
def self.to_csv
attributes = self.attribute_names
CSV.generate(headers: true) do |csv|
csv << attributes.first(15)
Similar blocks of code found in 2 locations. Consider refactoring.
def self.to_csv
attributes = self.attribute_names
CSV.generate(headers: true) do |csv|
csv << attributes.first(14)
Method edit
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def edit
@tutee = Tutee.find params[:tutee_id]
@evaluation = Evaluation.friendly.find params[:id]
@meeting = Meeting.where("evaluation_id = ?", @evaluation.id).first
if not @meeting.nil? and not @meeting.set_time.nil?
Method create
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def create
if request_params[:subject].blank?
flash[:notice] = "Invalid request: Subject should be filled out."
Method update
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def update
@evaluation = Evaluation.friendly.find params[:id]
took_place = (params['hours'].to_d > 0)
@evaluation.update(took_place: took_place, course: params['course'], hours: params['hours'], status: "Complete")
Similar blocks of code found in 2 locations. Consider refactoring.
def invite_student(tutor_id, tutee_id, request_id, tutor_message)
@tutor = Tutor.find_by_id(tutor_id)
@tutee = Tutee.find_by_id(tutee_id)
@request = Request.find_by_id(request_id)
@tutor_message = tutor_message
Similar blocks of code found in 2 locations. Consider refactoring.
def meeting_confirmation(tutor_id, tutee_id, message, request_id)
@tutor = Tutor.find_by_id(tutor_id)
@tutee = Tutee.find_by_id(tutee_id)
@request = Request.find_by_id(request_id)
@message = message
Similar blocks of code found in 2 locations. Consider refactoring.
def self.to_csv
attributes = Meeting.attribute_names
CSV.generate(headers: true) do |csv|
csv << attributes
Similar blocks of code found in 2 locations. Consider refactoring.
def self.to_csv
attributes = Request.attribute_names
CSV.generate(headers: true) do |csv|
csv << attributes