2019-04-10 10:36:53 Ruby

Ruby

Copy Copied! Full
# frozen_string_literal: true module Assessment class AssessmentRequestFilterSetsGetService attr_reader :result def initialize(jwt) @jwt = jwt binding.pry end def run! recently_used_filters = [] # 使用したフィルターの直近5件を取得する AssessmentItemFilter.where( # search_execution_employee_idの値とjwt_employee_id値は同じかは要確認 AssesmentItemFilterHistories.where(search_execution_employee_id: @jwt[:preferred_username]).order(search_date: :DESC).limit(5) ).each do |filter| assessment_request_filter = Gyro::Assessment::V1::AssessmentRequestFilterSet.new( customer_name: filter.customer_name, customer_kana_name: filter.customer_kana_name, customer_id: filter.customer_id, proposition_id: filter.proposition_id, assessment_item_id: filter.assessment_item_id, assessment_item_types: filter.assessment_item_types, assessment_types: filter.assessment_types, assessment_work_statuses: filter.assessment_work_statuses, is_request_assessment: filter.is_request_assessment, assessment_request_statuses: filter.assessment_request_statuses, registration_type: filter.registration_type, registration_date_from: filter.registration_date_from, registration_date_to: filter.registration_date_to, assessment_due_type: filter.assessment_due_type, assessment_due_date_from: filter.assessment_due_date_from, assessment_due_date_to: filterassessment_due_date_to, registration_employee_id: filter.registration_employee_id, primary_assessment_employee_id: filter.primary_assessment_employee_id, under_assessment_employee_id: filter.under_assessment_employee_id, is_summarized_for_proposition: filter.is_summarized_for_proposition ) recently_used_filters.push(assessment_request_filter) end organization_registered_filters = [] AssessmentItemFilter.where(organization_id: @jwt[:organization_id]).each do |filter| assessment_request_filter = Gyro::Assessment::V1::AssessmentRequestFilterSet.new( customer_name: filter.customer_name, customer_kana_name: filter.customer_kana_name, customer_id: filter.customer_id, proposition_id: filter.proposition_id, assessment_item_id: filter.assessment_item_id, assessment_item_types: filter.assessment_item_types, assessment_types: filter.assessment_types, assessment_work_statuses: filter.assessment_work_statuses, is_request_assessment: filter.is_request_assessment, assessment_request_statuses: filter.assessment_request_statuses, registration_type: filter.registration_type, registration_date_from: filter.registration_date_from, registration_date_to: filter.registration_date_to, assessment_due_type: filter.assessment_due_type, assessment_due_date_from: filter.assessment_due_date_from, assessment_due_date_to: filterassessment_due_date_to, registration_employee_id: filter.registration_employee_id, primary_assessment_employee_id: filter.primary_assessment_employee_id, under_assessment_employee_id: filter.under_assessment_employee_id, is_summarized_for_proposition: filter.is_summarized_for_proposition ) organization_registered_filters.push(assessment_request_filter) end individual_registered_filters = [] AssessmentItemFilter.where(register_employee_id: @jwt[:register_employee_id]).each do |filter| assessment_request_filter = Gyro::Assessment::V1::AssessmentRequestFilterSet.new( customer_name: filter.customer_name, customer_kana_name: filter.customer_kana_name, customer_id: filter.customer_id, proposition_id: filter.proposition_id, assessment_item_id: filter.assessment_item_id, assessment_item_types: filter.assessment_item_types, assessment_types: filter.assessment_types, assessment_work_statuses: filter.assessment_work_statuses, is_request_assessment: filter.is_request_assessment, assessment_request_statuses: filter.assessment_request_statuses, registration_type: filter.registration_type, registration_date_from: filter.registration_date_from, registration_date_to: filter.registration_date_to, assessment_due_type: filter.assessment_due_type, assessment_due_date_from: filter.assessment_due_date_from, assessment_due_date_to: filterassessment_due_date_to, registration_employee_id: filter.registration_employee_id, primary_assessment_employee_id: filter.primary_assessment_employee_id, under_assessment_employee_id: filter.under_assessment_employee_id, is_summarized_for_proposition: filter.is_summarized_for_proposition ) individual_registered_filter.push(assessment_request_filter) end @result = { # recently: recently_used_filters, organization: organization_registered_filters, individual: individual_registered_filters } end end end
RECOMMEND