Last active
November 30, 2017 14:58
-
-
Save absyah/a07901fc31ae12a29684e58aa689d533 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def priority_setting | |
@ahp_setting = current_user.ahp_setting | |
unless @ahp_setting.blank? | |
@pairwise = Matrix.identity(7).to_a | |
arr = [] | |
@ahp_setting.attributes.each do |i, val| | |
unless i == "id" || i == "user_id" || i == "created_at" || i == "updated_at" | |
arr = arr << val | |
end | |
end | |
handler = 1 | |
row = 0 | |
col = 0 | |
i = 0 | |
while handler <= 6 | |
col = handler | |
while col <= 6 | |
@pairwise[row][col] = (arr[i]) | |
@pairwise[col][row] = (1/arr[i]) | |
i += 1 | |
col += 1 | |
end | |
handler += 1 | |
row += 1 | |
end | |
pairwise_matrices = Matrix.rows(@pairwise) ** 2 | |
# adjust to display purpose ========================== | |
@pairwise_matrices = pairwise_matrices.to_a | |
# ==================================================== | |
cgp = pairwise_matrices.row(0).to_a.sum | |
acr = pairwise_matrices.row(1).to_a.sum | |
per = pairwise_matrices.row(2).to_a.sum | |
sch = pairwise_matrices.row(3).to_a.sum | |
tfl = pairwise_matrices.row(4).to_a.sum | |
cer = pairwise_matrices.row(5).to_a.sum | |
org = pairwise_matrices.row(6).to_a.sum | |
# adjust to display purpose ========================== | |
@cgp = cgp | |
@acr = acr | |
@per = per | |
@sch = sch | |
@tfl = tfl | |
@cer = cer | |
@org = org | |
# ==================================================== | |
normalizator = cgp + acr + per + sch + tfl + cer + org | |
# adjust to display purpose ========================== | |
@normalizator = normalizator | |
# ==================================================== | |
@cgp_prior = (cgp / normalizator) | |
@acr_prior = (acr / normalizator) | |
@per_prior = (per / normalizator) | |
@sch_prior = (sch / normalizator) | |
@tfl_prior = (tfl / normalizator) | |
@cer_prior = (cer / normalizator) | |
@org_prior = (org / normalizator) | |
@sum = (@cgp_prior + @acr_prior + @per_prior + @sch_prior + @tfl_prior + @cer_prior + @org_prior) | |
if current_user.ahp_summary.blank? | |
current_user.build_ahp_summary(:cgp_priority => @cgp_prior, | |
:acr_priority => @acr_prior, | |
:per_priority => @per_prior, | |
:sch_priority => @sch_prior, | |
:tfl_priority => @tfl_prior, | |
:cer_priority => @cer_prior, | |
:org_priority => @org_prior | |
).save | |
else | |
current_user.ahp_summary.update_attributes(:cgp_priority => @cgp_prior, | |
:acr_priority => @acr_prior, | |
:per_priority => @per_prior, | |
:sch_priority => @sch_prior, | |
:tfl_priority => @tfl_prior, | |
:cer_priority => @cer_prior, | |
:org_priority => @org_prior | |
) | |
end | |
end | |
respond_to do |format| | |
format.html | |
format.json { render json: @ahp_settings } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def search_results | |
@requested_applicants = current_user.requests | |
#@results = current_user.results.find(:all, :order => "result DESC") | |
temp = current_user.results.find(:all, :order => "result DESC") | |
@results = [] | |
temp.each do |x| | |
token = false | |
@requested_applicants.each do |requested_applicant| | |
if x.applicant_id == requested_applicant.applicant_id | |
token = true | |
end | |
end | |
unless token == true | |
@results << x | |
end | |
end | |
@search_results = [] | |
if params[:search_type] == "Name" | |
@keyword = params[:search_by_text] | |
@results.each do |result| | |
applicant = ApplicantProfile.search_by_name(result.applicant_id, params[:search_by_text]) | |
unless applicant.blank? | |
@search_results << result | |
end | |
end | |
elsif params[:search_type] == "University" | |
@keyword = params[:search_by_text] | |
universities = University.search_by_name(params[:search_by_text]) | |
@results.each do |result| | |
universities.each do |university| | |
applicant = ApplicantAsset.search_by_university(result.applicant_id, university.id) | |
unless applicant.blank? | |
@search_results << result | |
end | |
end | |
end | |
elsif params[:search_type] == "Certificate Type" | |
@keyword = params[:search_by_cer_type] | |
@results.each do |result| | |
applicant = ApplicantAsset.find_by_user_id(result.applicant_id) | |
unless applicant.certificates.blank? | |
certificate_type = applicant.certificates.certificate_type_text(params[:search_by_cer_type]).count | |
unless certificate_type == 0 | |
@search_results << result | |
end | |
end | |
end | |
elsif params[:search_type] == "Certificate Scope" | |
@keyword = params[:search_by_cer_scope] | |
@results.each do |result| | |
applicant = ApplicantAsset.find_by_user_id(result.applicant_id) | |
unless applicant.certificates.blank? | |
certificate_scope = applicant.certificates.certificate_scope_text(params[:search_by_cer_scope]).count | |
unless certificate_scope == 0 | |
@search_results << result | |
end | |
end | |
end | |
else | |
@keyword = params[:search_by_org] | |
@results.each do |result| | |
applicant = ApplicantAsset.find_by_user_id(result.applicant_id) | |
unless applicant.organizational_experiences.blank? | |
organizational_position = applicant.organizational_experiences.organizational_experience_as_text(params[:search_by_org]).count | |
#organizational_position = applicant.organizational_experiences.find_by_organizational_position_type_id(id) | |
unless organizational_position == 0 | |
@search_results << result | |
end | |
end | |
end | |
end | |
@applicants = [] | |
@profiles = [] | |
@assets = [] | |
@search_results.each do |search_result| | |
@applicants << User.find_by_id(search_result.applicant_id) | |
@profiles << ApplicantProfile.find_by_user_id(search_result.applicant_id) | |
@assets << AssetValue.find_by_user_id(search_result.applicant_id) | |
end | |
@search_type_information = params[:search_type] | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment