Prod build process
This commit is contained in:
@@ -20,55 +20,56 @@ module EmployerAutomation
|
||||
}
|
||||
|
||||
scope :in_automation_initilization, -> {
|
||||
joins(:id_card_setup)
|
||||
left_outer_joins(:id_card_setup)
|
||||
.where(initialized: false)
|
||||
.or(
|
||||
where(id_card_setup: {initialized: false})
|
||||
)
|
||||
).distinct
|
||||
}
|
||||
|
||||
# scope :missing_keychain_values, -> {
|
||||
# where(company_pb_entity_key: [nil, ''])
|
||||
# .or(where(plan_id: [nil, '']))
|
||||
# .or(where(group_number: [nil, '']))
|
||||
# .or(where(pl_plan_key: [nil, '']))
|
||||
# }
|
||||
|
||||
scope :missing_keychain_initialization, -> {
|
||||
uninitialized.automation_ready
|
||||
}
|
||||
|
||||
scope :uninitialized_id_card_setup, -> {
|
||||
joins(:id_card_setup)
|
||||
left_outer_joins(:id_card_setup)
|
||||
.where(id_card_setup: {initialized: false})
|
||||
}
|
||||
|
||||
scope :missing_plans, -> {
|
||||
where.missing(:plans)
|
||||
.or(
|
||||
where(
|
||||
id: joins(:plans)
|
||||
.where(plans: { pb_product_key: [nil, ''] })
|
||||
.select(:id)
|
||||
)
|
||||
)
|
||||
left_outer_joins(:plans)
|
||||
.where(id_card_plans: { pb_product_key: [nil, ""] })
|
||||
.distinct
|
||||
}
|
||||
|
||||
scope :has_plans, -> {
|
||||
where.associated(:plans)
|
||||
.where.not(
|
||||
id: joins(:plans)
|
||||
.where(plans: { pb_product_key: [nil, ''] })
|
||||
.select(:id)
|
||||
).distinct
|
||||
left_outer_joins(:plans)
|
||||
.where("id_card_plans.pb_product_key IS NOT NULL AND id_card_plans.pb_product_key != ''")
|
||||
.distinct
|
||||
}
|
||||
|
||||
scope :missing_members, -> {
|
||||
left_outer_joins(:members)
|
||||
.where(members: { id: nil })
|
||||
.distinct
|
||||
}
|
||||
|
||||
scope :has_members, -> {
|
||||
left_outer_joins(:members)
|
||||
.where.not(members: { id: nil })
|
||||
.distinct
|
||||
}
|
||||
|
||||
scope :missing_plans_initialization, -> {
|
||||
uninitialized_id_card_setup.missing_plans
|
||||
initialized.uninitialized_id_card_setup.missing_plans
|
||||
}
|
||||
|
||||
scope :missing_members_initialization, -> {
|
||||
uninitialized_id_card_setup.has_plans
|
||||
initialized.uninitialized_id_card_setup.has_plans.missing_members
|
||||
}
|
||||
|
||||
scope :ready_for_id_card_activation, -> {
|
||||
initialized.uninitialized_id_card_setup.has_members
|
||||
}
|
||||
|
||||
scope :with_active_id_card_setup, -> {
|
||||
@@ -76,62 +77,11 @@ module EmployerAutomation
|
||||
.where(id_card_setup: {active: true})
|
||||
}
|
||||
|
||||
# scope :with_keychain_values, -> {
|
||||
# where.not(
|
||||
# pl_plan_key: [nil, ''],
|
||||
# group_number: [nil, ''],
|
||||
# company_pb_entity_key: [nil, ''],
|
||||
# plan_id: [nil, '']
|
||||
# )
|
||||
# }
|
||||
|
||||
scope :deactivated, -> {
|
||||
inactive.initialized
|
||||
}
|
||||
# Employer.joins(:id_card_setup)
|
||||
# .left_outer_joins(:plans)
|
||||
# .where(plans: { pb_product_key: [nil, ''] })
|
||||
|
||||
# .group('users.id') # Group by user ID
|
||||
# .having('COUNT(posts.id) = 0')
|
||||
|
||||
# Employer.left_outer_joins(:plans)
|
||||
# .where(plans: { id: nil })
|
||||
# .or(Employer.where(plans: { pb_product_key: [nil, ''] }))
|
||||
|
||||
# Employer.where.missing(:plans)
|
||||
# .or(Employer.joins(:plans).where(plans: { pb_product_key: [nil, ''] }))
|
||||
|
||||
# Employer.joins(id_card_setup: :plans).where.not("plans.id_card_setup_id = id_card_setup.id").or
|
||||
# (where(plans: { pb_product_key: [nil, ''] }))
|
||||
|
||||
# scope :with_survey_and_no_questions, -> {
|
||||
# joins(:survey) # join has_one
|
||||
# .left_joins(survey: :questions) # join has_many through has_one
|
||||
# .where(questions: { id: nil }) # filter where has_many is empty
|
||||
# }
|
||||
|
||||
# scope :missing_initial_members, -> {
|
||||
# new_groups.with_plans
|
||||
# }
|
||||
end
|
||||
|
||||
# class_methods do
|
||||
# # Methods in this block become class methods of the including class.
|
||||
# def count_all_visible
|
||||
# visible.count
|
||||
# end
|
||||
# end
|
||||
|
||||
# Any other methods defined here become instance methods automatically.
|
||||
# def up_to_date?
|
||||
# self.pl_plan_key.present? &&
|
||||
# self.company_pb_entity_key.present? &&
|
||||
# self.plan_id.present? &&
|
||||
# self.group_number.present? &&
|
||||
# self.effective_date.present?
|
||||
# end
|
||||
|
||||
def sync_members_with_vhcs
|
||||
AutomationService::EmployerMembersUpdate.new(pl_plan_key).call
|
||||
end
|
||||
|
||||
@@ -1,29 +1,6 @@
|
||||
module MemberAutomation
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# included do
|
||||
# # Code in this block becomes instance methods or class macros (like scopes, validations, associations) in the including class.
|
||||
# scope :visible, -> { where(visible: true) }
|
||||
# scope :invisible, -> { where(visible: false) }
|
||||
# validates :status, inclusion: { in: %w(visible invisible), message: "%{value} is not a valid status" }
|
||||
# end
|
||||
|
||||
# class_methods do
|
||||
# # Methods in this block become class methods of the including class.
|
||||
# def count_all_visible
|
||||
# visible.count
|
||||
# end
|
||||
# end
|
||||
|
||||
# Any other methods defined here become instance methods automatically.
|
||||
# def up_to_date?
|
||||
# self.pl_plan_key.present? &&
|
||||
# self.company_pb_entity_key.present? &&
|
||||
# self.plan_id.present? &&
|
||||
# self.group_number.present? &&
|
||||
# self.effective_date.present?
|
||||
# end
|
||||
|
||||
def sync_with_vhcs
|
||||
AutomationService::MemberUpdate.new(self.employer.pl_plan_key, self.pb_entity_key).call
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user