diff --git a/.rubocop.yml b/.rubocop.yml index da24368f4..05b036fd3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -40,4 +40,3 @@ AllCops: - config/routes.rb - app/services/kps/omu/adres.rb # WIP - app/services/kps/omu/kimlik.rb # WIP - - app/jobs/yoksis_publications_create_job.rb # WIP diff --git a/Gemfile.lock b/Gemfile.lock index d26acbdee..fb65a6be7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -113,7 +113,7 @@ GEM dotenv-rails (2.5.0) dotenv (= 2.5.0) railties (>= 3.2, < 6.0) - email_address (0.1.9) + email_address (0.1.10) netaddr (~> 2.0) simpleidn equalizer (0.0.11) @@ -169,7 +169,7 @@ GEM mini_portile2 (~> 2.3.0) nori (2.6.0) orm_adapter (0.5.0) - pagy (0.11.2) + pagy (0.12.0) parallel (1.12.1) parser (2.5.1.0) ast (~> 2.4.0) @@ -231,7 +231,7 @@ GEM railties (>= 4.2.0, < 5.3) rollbar (2.16.2) multi_json - rubocop (0.57.2) + rubocop (0.58.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.5) diff --git a/app/controllers/concerns/reference_resource.rb b/app/controllers/concerns/reference_resource.rb new file mode 100644 index 000000000..e4e029bfd --- /dev/null +++ b/app/controllers/concerns/reference_resource.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module ReferenceResource + extend ActiveSupport::Concern + include Pagy::Backend + + # rubocop:disable Metrics/BlockLength + # rubocop:disable Rails/LexicallyScopedActionFilter + included do + before_action :set_variables + before_action :set_resource, only: %i[edit update destroy] + + def index + @pagy, value = pagy(@model_name.all) + instance_variable_set("@#{controller_name}", value) + end + + def new + instance_variable_set(@singular_variable.to_sym, @model_name.new) + end + + def create + instance_variable_set(@singular_variable.to_sym, @model_name.new(secure_params)) + instance_variable_get(@singular_variable).save ? redirect_with('success') : render(:new) + end + + def update + if instance_variable_get(@singular_variable).update(secure_params) + flash[:notice] = t('.success') + redirect_to action: :index + else + render(:edit) + end + end + + def destroy + instance_variable_get(@singular_variable).destroy ? redirect_with('success') : redirect_with('warning') + end + + private + + def set_variables + @singular_variable = "@#{controller_name.singularize}" + @model_name = controller_name.classify.constantize + end + + def set_resource + instance_variable_set(@singular_variable.to_sym, @model_name.find(params[:id])) + end + + def redirect_with(message) + redirect_to(send("#{controller_name}_path"), notice: t(".#{message}")) + end + end + # rubocop:enable Metrics/BlockLength + # rubocop:enable Rails/LexicallyScopedActionFilter +end diff --git a/app/controllers/references/student_disability_types_controller.rb b/app/controllers/references/student_disability_types_controller.rb index 30f5e6853..25930b07e 100644 --- a/app/controllers/references/student_disability_types_controller.rb +++ b/app/controllers/references/student_disability_types_controller.rb @@ -2,48 +2,11 @@ module References class StudentDisabilityTypesController < ApplicationController - include Pagy::Backend - - before_action :set_student_disability_type, only: %i[edit update destroy] - - def index - @pagy, @student_disability_types = pagy(StudentDisabilityType.all) - end - - def new - @student_disability_type = StudentDisabilityType.new - end - - def edit; end - - def create - @student_disability_type = StudentDisabilityType.new(student_disability_type_params) - @student_disability_type.save ? redirect_with('success') : render(:new) - end - - def update - if @student_disability_type.update(student_disability_type_params) - redirect_to(@student_disability_type, notice: t('.success')) - else - render(:edit) - end - end - - def destroy - @student_disability_type.destroy ? redirect_with('success') : redirect_with('warning') - end + include ReferenceResource private - def redirect_with(message) - redirect_to(student_disability_types_path, notice: t(".#{message}")) - end - - def set_student_disability_type - @student_disability_type = StudentDisabilityType.find(params[:id]) - end - - def student_disability_type_params + def secure_params params.require(:student_disability_type).permit(:name, :code) end end diff --git a/app/controllers/references/student_drop_out_types_controller.rb b/app/controllers/references/student_drop_out_types_controller.rb index b1960f41c..2ee68a1a2 100644 --- a/app/controllers/references/student_drop_out_types_controller.rb +++ b/app/controllers/references/student_drop_out_types_controller.rb @@ -2,48 +2,11 @@ module References class StudentDropOutTypesController < ApplicationController - include Pagy::Backend - - before_action :set_student_drop_out_type, only: %i[edit update destroy] - - def index - @pagy, @student_drop_out_types = pagy(StudentDropOutType.all) - end - - def new - @student_drop_out_type = StudentDropOutType.new - end - - def edit; end - - def create - @student_drop_out_type = StudentDropOutType.new(student_drop_out_type_params) - @student_drop_out_type.save ? redirect_with('success') : render(:new) - end - - def update - if @student_drop_out_type.update(student_drop_out_type_params) - redirect_to(@student_drop_out_type, notice: t('.success')) - else - render(:edit) - end - end - - def destroy - @student_drop_out_type.destroy ? redirect_with('success') : redirect_with('warning') - end + include ReferenceResource private - def redirect_with(message) - redirect_to(student_drop_out_types_path, notice: t(".#{message}")) - end - - def set_student_drop_out_type - @student_drop_out_type = StudentDropOutType.find(params[:id]) - end - - def student_drop_out_type_params + def secure_params params.require(:student_drop_out_type).permit(:name, :code) end end diff --git a/app/controllers/references/student_education_levels_controller.rb b/app/controllers/references/student_education_levels_controller.rb index a788558f6..644cb5533 100644 --- a/app/controllers/references/student_education_levels_controller.rb +++ b/app/controllers/references/student_education_levels_controller.rb @@ -2,48 +2,11 @@ module References class StudentEducationLevelsController < ApplicationController - include Pagy::Backend - - before_action :set_student_education_level, only: %i[edit update destroy] - - def index - @pagy, @student_education_levels = pagy(StudentEducationLevel.all) - end - - def new - @student_education_level = StudentEducationLevel.new - end - - def edit; end - - def create - @student_education_level = StudentEducationLevel.new(student_education_level_params) - @student_education_level.save ? redirect_with('success') : render(:new) - end - - def update - if @student_education_level.update(student_education_level_params) - redirect_to(@student_education_level, notice: t('.success')) - else - render(:edit) - end - end - - def destroy - @student_education_level.destroy ? redirect_with('success') : redirect_with('warning') - end + include ReferenceResource private - def redirect_with(message) - redirect_to(student_education_levels_path, notice: t(".#{message}")) - end - - def set_student_education_level - @student_education_level = StudentEducationLevel.find(params[:id]) - end - - def student_education_level_params + def secure_params params.require(:student_education_level).permit(:name, :code) end end diff --git a/app/controllers/references/student_entrance_point_types_controller.rb b/app/controllers/references/student_entrance_point_types_controller.rb index edad38957..5089f35f3 100644 --- a/app/controllers/references/student_entrance_point_types_controller.rb +++ b/app/controllers/references/student_entrance_point_types_controller.rb @@ -2,48 +2,11 @@ module References class StudentEntrancePointTypesController < ApplicationController - include Pagy::Backend - - before_action :set_student_entrance_point_type, only: %i[edit update destroy] - - def index - @pagy, @student_entrance_point_types = pagy(StudentEntrancePointType.all) - end - - def new - @student_entrance_point_type = StudentEntrancePointType.new - end - - def edit; end - - def create - @student_entrance_point_type = StudentEntrancePointType.new(student_entrance_point_type_params) - @student_entrance_point_type.save ? redirect_with('success') : render(:new) - end - - def update - if @student_entrance_point_type.update(student_entrance_point_type_params) - redirect_to(@student_entrance_point_type, notice: t('.success')) - else - render(:edit) - end - end - - def destroy - @student_entrance_point_type.destroy ? redirect_with('success') : redirect_with('warning') - end + include ReferenceResource private - def redirect_with(message) - redirect_to(student_entrance_point_types_path, notice: t(".#{message}")) - end - - def set_student_entrance_point_type - @student_entrance_point_type = StudentEntrancePointType.find(params[:id]) - end - - def student_entrance_point_type_params + def secure_params params.require(:student_entrance_point_type).permit(:name, :code) end end diff --git a/app/controllers/references/student_entrance_types_controller.rb b/app/controllers/references/student_entrance_types_controller.rb index ce0da5fa9..9d99f0614 100644 --- a/app/controllers/references/student_entrance_types_controller.rb +++ b/app/controllers/references/student_entrance_types_controller.rb @@ -2,48 +2,11 @@ module References class StudentEntranceTypesController < ApplicationController - include Pagy::Backend - - before_action :set_student_entrance_type, only: %i[edit update destroy] - - def index - @pagy, @student_entrance_types = pagy(StudentEntranceType.all) - end - - def new - @student_entrance_type = StudentEntranceType.new - end - - def edit; end - - def create - @student_entrance_type = StudentEntranceType.new(student_entrance_type_params) - @student_entrance_type.save ? redirect_with('success') : render(:new) - end - - def update - if @student_entrance_type.update(student_entrance_type_params) - redirect_to(@student_entrance_type, notice: t('.success')) - else - render(:edit) - end - end - - def destroy - @student_entrance_type.destroy ? redirect_with('success') : redirect_with('warning') - end + include ReferenceResource private - def redirect_with(message) - redirect_to(student_entrance_types_path, notice: t(".#{message}")) - end - - def set_student_entrance_type - @student_entrance_type = StudentEntranceType.find(params[:id]) - end - - def student_entrance_type_params + def secure_params params.require(:student_entrance_type).permit(:name, :code) end end diff --git a/app/controllers/references/student_grades_controller.rb b/app/controllers/references/student_grades_controller.rb index 6ee261624..5ee716749 100644 --- a/app/controllers/references/student_grades_controller.rb +++ b/app/controllers/references/student_grades_controller.rb @@ -2,48 +2,11 @@ module References class StudentGradesController < ApplicationController - include Pagy::Backend - - before_action :set_student_grade, only: %i[edit update destroy] - - def index - @pagy, @student_grades = pagy(StudentGrade.all) - end - - def new - @student_grade = StudentGrade.new - end - - def edit; end - - def create - @student_grade = StudentGrade.new(student_grade_params) - @student_grade.save ? redirect_with('success') : render(:new) - end - - def update - if @student_grade.update(student_grade_params) - redirect_to(@student_grade, notice: t('.success')) - else - render(:edit) - end - end - - def destroy - @student_grade.destroy ? redirect_with('success') : redirect_with('warning') - end + include ReferenceResource private - def redirect_with(message) - redirect_to(student_grades_path, notice: t(".#{message}")) - end - - def set_student_grade - @student_grade = StudentGrade.find(params[:id]) - end - - def student_grade_params + def secure_params params.require(:student_grade).permit(:name, :code) end end diff --git a/app/controllers/references/student_grading_systems_controller.rb b/app/controllers/references/student_grading_systems_controller.rb index 1d5b167b5..3bebc0564 100644 --- a/app/controllers/references/student_grading_systems_controller.rb +++ b/app/controllers/references/student_grading_systems_controller.rb @@ -2,48 +2,11 @@ module References class StudentGradingSystemsController < ApplicationController - include Pagy::Backend - - before_action :set_student_grading_system, only: %i[edit update destroy] - - def index - @pagy, @student_grading_systems = pagy(StudentGradingSystem.all) - end - - def new - @student_grading_system = StudentGradingSystem.new - end - - def edit; end - - def create - @student_grading_system = StudentGradingSystem.new(student_grading_system_params) - @student_grading_system.save ? redirect_with('success') : render(:new) - end - - def update - if @student_grading_system.update(student_grading_system_params) - redirect_to(@student_grading_system, notice: t('.success')) - else - render(:edit) - end - end - - def destroy - @student_grading_system.destroy ? redirect_with('success') : redirect_with('warning') - end + include ReferenceResource private - def redirect_with(message) - redirect_to(student_grading_systems_path, notice: t(".#{message}")) - end - - def set_student_grading_system - @student_grading_system = StudentGradingSystem.find(params[:id]) - end - - def student_grading_system_params + def secure_params params.require(:student_grading_system).permit(:name, :code) end end diff --git a/app/controllers/references/student_punishment_types_controller.rb b/app/controllers/references/student_punishment_types_controller.rb index 1d548bd96..f862eac8e 100644 --- a/app/controllers/references/student_punishment_types_controller.rb +++ b/app/controllers/references/student_punishment_types_controller.rb @@ -2,48 +2,11 @@ module References class StudentPunishmentTypesController < ApplicationController - include Pagy::Backend - - before_action :set_student_punishment_type, only: %i[edit update destroy] - - def index - @pagy, @student_punishment_types = pagy(StudentPunishmentType.all) - end - - def new - @student_punishment_type = StudentPunishmentType.new - end - - def edit; end - - def create - @student_punishment_type = StudentPunishmentType.new(student_punishment_type_params) - @student_punishment_type.save ? redirect_with('success') : render(:new) - end - - def update - if @student_punishment_type.update(student_punishment_type_params) - redirect_to(@student_punishment_type, notice: t('.success')) - else - render(:edit) - end - end - - def destroy - @student_punishment_type.destroy ? redirect_with('success') : redirect_with('warning') - end + include ReferenceResource private - def redirect_with(message) - redirect_to(student_punishment_types_path, notice: t(".#{message}")) - end - - def set_student_punishment_type - @student_punishment_type = StudentPunishmentType.find(params[:id]) - end - - def student_punishment_type_params + def secure_params params.require(:student_punishment_type).permit(:name, :code) end end diff --git a/app/controllers/references/student_studentship_statuses_controller.rb b/app/controllers/references/student_studentship_statuses_controller.rb index 8072dc334..e8f06ec05 100644 --- a/app/controllers/references/student_studentship_statuses_controller.rb +++ b/app/controllers/references/student_studentship_statuses_controller.rb @@ -2,48 +2,11 @@ module References class StudentStudentshipStatusesController < ApplicationController - include Pagy::Backend - - before_action :set_student_studentship_status, only: %i[edit update destroy] - - def index - @pagy, @student_studentship_statuses = pagy(StudentStudentshipStatus.all) - end - - def new - @student_studentship_status = StudentStudentshipStatus.new - end - - def edit; end - - def create - @student_studentship_status = StudentStudentshipStatus.new(student_studentship_status_params) - @student_studentship_status.save ? redirect_with('success') : render(:new) - end - - def update - if @student_studentship_status.update(student_studentship_status_params) - redirect_to(@student_studentship_status, notice: t('.success')) - else - render(:edit) - end - end - - def destroy - @student_studentship_status.destroy ? redirect_with('success') : redirect_with('warning') - end + include ReferenceResource private - def redirect_with(message) - redirect_to(student_studentship_statuses_path, notice: t(".#{message}")) - end - - def set_student_studentship_status - @student_studentship_status = StudentStudentshipStatus.find(params[:id]) - end - - def student_studentship_status_params + def secure_params params.require(:student_studentship_status).permit(:name, :code) end end diff --git a/app/controllers/references/unit_instruction_languages_controller.rb b/app/controllers/references/unit_instruction_languages_controller.rb index 7eaac85c9..829f945e3 100644 --- a/app/controllers/references/unit_instruction_languages_controller.rb +++ b/app/controllers/references/unit_instruction_languages_controller.rb @@ -2,48 +2,11 @@ module References class UnitInstructionLanguagesController < ApplicationController - include Pagy::Backend - - before_action :set_unit_instruction_language, only: %i[edit update destroy] - - def index - @pagy, @unit_instruction_languages = pagy(UnitInstructionLanguage.all) - end - - def new - @unit_instruction_language = UnitInstructionLanguage.new - end - - def edit; end - - def create - @unit_instruction_language = UnitInstructionLanguage.new(unit_instruction_language_params) - @unit_instruction_language.save ? redirect_with('success') : render(:new) - end - - def update - if @unit_instruction_language.update(unit_instruction_language_params) - redirect_to(@unit_instruction_language, notice: t('.success')) - else - render(:edit) - end - end - - def destroy - @unit_instruction_language.destroy ? redirect_with('success') : redirect_with('warning') - end + include ReferenceResource private - def redirect_with(message) - redirect_to(unit_instruction_languages_path, notice: t(".#{message}")) - end - - def set_unit_instruction_language - @unit_instruction_language = UnitInstructionLanguage.find(params[:id]) - end - - def unit_instruction_language_params + def secure_params params.require(:unit_instruction_language).permit(:name, :code) end end diff --git a/app/controllers/references/unit_instruction_types_controller.rb b/app/controllers/references/unit_instruction_types_controller.rb index e62801be3..53acb72d8 100644 --- a/app/controllers/references/unit_instruction_types_controller.rb +++ b/app/controllers/references/unit_instruction_types_controller.rb @@ -2,48 +2,11 @@ module References class UnitInstructionTypesController < ApplicationController - include Pagy::Backend - - before_action :set_unit_instruction_type, only: %i[edit update destroy] - - def index - @pagy, @unit_instruction_types = pagy(UnitInstructionType.all) - end - - def new - @unit_instruction_type = UnitInstructionType.new - end - - def edit; end - - def create - @unit_instruction_type = UnitInstructionType.new(unit_instruction_type_params) - @unit_instruction_type.save ? redirect_with('success') : render(:new) - end - - def update - if @unit_instruction_type.update(unit_instruction_type_params) - redirect_to(@unit_instruction_type, notice: t('.success')) - else - render(:edit) - end - end - - def destroy - @unit_instruction_type.destroy ? redirect_with('success') : redirect_with('warning') - end + include ReferenceResource private - def redirect_with(message) - redirect_to(unit_instruction_types_path, notice: t(".#{message}")) - end - - def set_unit_instruction_type - @unit_instruction_type = UnitInstructionType.find(params[:id]) - end - - def unit_instruction_type_params + def secure_params params.require(:unit_instruction_type).permit(:name, :code) end end diff --git a/app/controllers/references/unit_statuses_controller.rb b/app/controllers/references/unit_statuses_controller.rb index 82e04b7f8..f34d75502 100644 --- a/app/controllers/references/unit_statuses_controller.rb +++ b/app/controllers/references/unit_statuses_controller.rb @@ -2,48 +2,11 @@ module References class UnitStatusesController < ApplicationController - include Pagy::Backend - - before_action :set_unit_status, only: %i[edit update destroy] - - def index - @pagy, @unit_statuses = pagy(UnitStatus.all) - end - - def new - @unit_status = UnitStatus.new - end - - def edit; end - - def create - @unit_status = UnitStatus.new(unit_status_params) - @unit_status.save ? redirect_with('success') : render(:new) - end - - def update - if @unit_status.update(unit_status_params) - redirect_to(@unit_status, notice: t('.success')) - else - render(:edit) - end - end - - def destroy - @unit_status.destroy ? redirect_with('success') : redirect_with('warning') - end + include ReferenceResource private - def redirect_with(message) - redirect_to(unit_statuses_path, notice: t(".#{message}")) - end - - def set_unit_status - @unit_status = UnitStatus.find(params[:id]) - end - - def unit_status_params + def secure_params params.require(:unit_status).permit(:name, :code) end end diff --git a/app/controllers/references/unit_types_controller.rb b/app/controllers/references/unit_types_controller.rb index b93e77c44..262d9545b 100644 --- a/app/controllers/references/unit_types_controller.rb +++ b/app/controllers/references/unit_types_controller.rb @@ -2,48 +2,11 @@ module References class UnitTypesController < ApplicationController - include Pagy::Backend - - before_action :set_unit_type, only: %i[edit update destroy] - - def index - @pagy, @unit_types = pagy(UnitType.all) - end - - def new - @unit_type = UnitType.new - end - - def edit; end - - def create - @unit_type = UnitType.new(unit_type_params) - @unit_type.save ? redirect_with('success') : render(:new) - end - - def update - if @unit_type.update(unit_type_params) - redirect_to(@unit_type, notice: t('.success')) - else - render(:edit) - end - end - - def destroy - @unit_type.destroy ? redirect_with('success') : redirect_with('warning') - end + include ReferenceResource private - def redirect_with(message) - redirect_to(unit_types_path, notice: t(".#{message}")) - end - - def set_unit_type - @unit_type = UnitType.find(params[:id]) - end - - def unit_type_params + def secure_params params.require(:unit_type).permit(:name, :code) end end diff --git a/app/controllers/references/university_types_controller.rb b/app/controllers/references/university_types_controller.rb index 135579d2e..b481fce03 100644 --- a/app/controllers/references/university_types_controller.rb +++ b/app/controllers/references/university_types_controller.rb @@ -2,48 +2,11 @@ module References class UniversityTypesController < ApplicationController - include Pagy::Backend - - before_action :set_university_type, only: %i[edit update destroy] - - def index - @pagy, @university_types = pagy(UniversityType.all) - end - - def new - @university_type = UniversityType.new - end - - def edit; end - - def create - @university_type = UniversityType.new(university_type_params) - @university_type.save ? redirect_with('success') : render(:new) - end - - def update - if @university_type.update(university_type_params) - redirect_to(@university_type, notice: t('.success')) - else - render(:edit) - end - end - - def destroy - @university_type.destroy ? redirect_with('success') : redirect_with('warning') - end + include ReferenceResource private - def redirect_with(message) - redirect_to(university_types_path, notice: t(".#{message}")) - end - - def set_university_type - @university_type = UniversityType.find(params[:id]) - end - - def university_type_params + def secure_params params.require(:university_type).permit(:name, :code) end end diff --git a/app/helpers/membership_notifications_helper.rb b/app/helpers/membership_notifications_helper.rb index 7888cfc63..0565c895c 100644 --- a/app/helpers/membership_notifications_helper.rb +++ b/app/helpers/membership_notifications_helper.rb @@ -9,9 +9,7 @@ def profile_completion_rate(user) end def password_change_progress_bar(user) - seconds_in_a_month = 30 * 24 * 60 * 60 last_password_change = Time.zone.now - user.password_changed_at - - last_password_change * 100 / seconds_in_a_month + last_password_change * 100 / 1.month.to_i end end diff --git a/app/jobs/yoksis_publications_create_job.rb b/app/jobs/yoksis_publications_create_job.rb index 05b54f68a..92ccc37c1 100644 --- a/app/jobs/yoksis_publications_create_job.rb +++ b/app/jobs/yoksis_publications_create_job.rb @@ -8,50 +8,30 @@ def perform(user) @response = Services::Yoksis::V1::Ozgecmis.new.certifications(user.id_number.to_i) end - # TODO: WIP. Will refactor. Experimental code! # callbacks after_perform do |job| user = job.arguments.first if @response[:sonuc][:durum_kodu].eql?('1') && @response[:arastirma_liste].present? - response = @response[:arastirma_liste] - if response.is_a?(Hash) + response = [@response[:arastirma_liste]].flatten + + response.each do |study| user.certifications.create( - yoksis_id: response[:s_id].to_i, - type: response[:tur_id].to_i, - name: response[:adi], - content: response[:icerik], - location: response[:yer], - scope: response[:kapsam].to_i, - duration: response[:sure], - start_date: response[:bastar], - end_date: response[:bittar], - title: response[:unvan_ad].capitalize_all, - number_of_authors: response[:kisi_sayisi], - city_and_country: response[:ulke_sehir], - last_update: response[:guncelleme_tarihi], - incentive_point: response[:tesv_puan], - status: response[:aktif_pasif].to_i + yoksis_id: study[:s_id].to_i, + type: study[:tur_id].to_i, + name: study[:adi], + content: study[:icerik], + location: study[:yer], + scope: study[:kapsam].to_i, + duration: study[:sure], + start_date: study[:bastar], + end_date: study[:bittar], + title: study[:unvan_ad].try(:capitalize_all), + number_of_authors: study[:kisi_sayisi], + city_and_country: study[:ulke_sehir], + last_update: study[:guncelleme_tarihi], + incentive_point: study[:tesv_puan], + status: study[:aktif_pasif].to_i ) - else - response.each do |study| - user.certifications.create( - yoksis_id: study[:s_id].to_i, - type: study[:tur_id].to_i, - name: study[:adi], - content: study[:icerik], - location: study[:yer], - scope: study[:kapsam].to_i, - duration: study[:sure], - start_date: study[:bastar], - end_date: study[:bittar], - title: study[:unvan_ad].capitalize_all, - number_of_authors: study[:kisi_sayisi], - city_and_country: study[:ulke_sehir], - last_update: study[:guncelleme_tarihi], - incentive_point: study[:tesv_puan], - status: study[:aktif_pasif].to_i - ) - end end end end diff --git a/app/services/kps/omu/adres.rb b/app/services/kps/omu/adres.rb index fccb16377..550c45b4f 100644 --- a/app/services/kps/omu/adres.rb +++ b/app/services/kps/omu/adres.rb @@ -15,27 +15,24 @@ def sorgula(queried_id_number) :adres_sorgula, message: message ).body[:adres_sorgula_response][:return][:sorgula_result][:sorgu_sonucu][:kimlik_noile_kisi_adres_bilgileri] - raise IdNumberError if response[:hata_bilgisi].present? - - yerlesim_yeri = response[:yerlesim_yeri_adresi] - address_root = if yerlesim_yeri[:il_ilce_merkez_adresi].present? - yerlesim_yeri[:il_ilce_merkez_adresi] - elsif yerlesim_yeri[:koy_adresi].present? - yerlesim_yeri[:koy_adresi] - elsif yerlesim_yeri[:yurt_disi_adresi].present? - yerlesim_yeri[:yurt_disi_adresi] - end - # return a hash, ready to use for building an Address. - address_information = { - full_address: yerlesim_yeri[:acik_adres], - district_id: address_root[:ilce_kodu].to_i - # city: address_root[:il], - # city_id: address_root[:il_kodu], - # district: address_root[:ilce], - # neighbourhood: address_root[:mahalle], - # neighbourhood_id: address_root[:mahalle_kodu] - } - address_information + if response[:hata_bilgisi].present? + raise IdNumberError i + else + yerlesim_yeri = response[:yerlesim_yeri_adresi] + address_root = if yerlesim_yeri[:il_ilce_merkez_adresi].present? + yerlesim_yeri[:il_ilce_merkez_adresi] + elsif yerlesim_yeri[:koy_adresi].present? + yerlesim_yeri[:koy_adresi] + elsif yerlesim_yeri[:yurt_disi_adresi].present? + yerlesim_yeri[:yurt_disi_adresi] + end + # return a hash, ready to use for building an Address. + address_information = { + full_address: yerlesim_yeri[:acik_adres], + district_id: address_root[:ilce_kodu].to_i + } + address_information + end end end end diff --git a/config/database.yml b/config/database.yml index ba91ba789..a220babc0 100644 --- a/config/database.yml +++ b/config/database.yml @@ -17,6 +17,8 @@ test: production: &production <<: *default url: <%= ENV['DATABASE_URL'] %> + pool: 40 + timeout: 5000 beta: <<: *production diff --git a/config/environments/production.rb b/config/environments/production.rb index 17c068393..f81d42569 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -71,6 +71,8 @@ # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false + config.action_mailer.default_url_options = { host: 'https://nokul.app.omu.sh' } + config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :address => 'smtp.gmail.com',