change registrant query

This commit is contained in:
oleghasjanov 2025-01-10 13:29:08 +02:00
parent 8a93a8b4d2
commit 92f82194e1

View file

@ -45,12 +45,14 @@ class CompanyRegisterStatusJob < ApplicationJob
end end
def sampling_registrant_contact(days_interval) def sampling_registrant_contact(days_interval)
Registrant.where(ident_type: 'org', ident_country_code: 'EE').where( Contact.joins(:registrant_domains)
"(company_register_status IS NULL OR checked_company_at IS NULL) OR .where(ident_type: 'org', ident_country_code: 'EE')
(company_register_status = ? AND checked_company_at < ?) OR .where(
company_register_status IN (?)", "(company_register_status IS NULL OR checked_company_at IS NULL) OR
Contact::REGISTERED, days_interval.days.ago, [Contact::LIQUIDATED, Contact::BANKRUPT, Contact::DELETED] (company_register_status = ? AND checked_company_at < ?) OR
) company_register_status IN (?)",
Contact::REGISTERED, 365.days.ago, [Contact::LIQUIDATED, Contact::BANKRUPT, Contact::DELETED]
).distinct
end end
def update_validation_company_status(contact:, status:) def update_validation_company_status(contact:, status:)