Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def self.verified
where.not(verified_at: nil)
end

def self.facial_match
where(idv_level: FACIAL_MATCH_IDV_LEVELS)
end

Comment thread
zachmargolis marked this conversation as resolved.
def self.fraud_rejection
where.not(fraud_rejection_at: nil)
end
Expand Down
23 changes: 12 additions & 11 deletions app/services/reporting/agency_and_sp_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ def agency_and_sp_emailable_report
end

def active_agencies
@active_agencies ||= Agreements::PartnerAccountStatus.find_by(name: 'active').
partner_accounts.
includes(:agency).
where('became_partner <= ?', report_date).
map(&:agency).
uniq
@active_agencies ||= Agency.joins(:partner_accounts).
where(partner_accounts: {
partner_account_status: Agreements::PartnerAccountStatus.find_by(name: 'active'),
became_partner: ..report_date,
}).
distinct

@MrNagoo MrNagoo Nov 29, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has a 2x speed improvement

end

def service_providers
Expand All @@ -67,11 +67,12 @@ def service_providers
end

def facial_match_issuers
@facial_match_issuers ||= Profile.where(active: true).where(
'verified_at <= ?',
report_date.end_of_day,
).where(idv_level: Profile::FACIAL_MATCH_IDV_LEVELS).
pluck(:initiating_service_provider_issuer).uniq
@facial_match_issuers ||= Reports::BaseReport.transaction_with_timeout do
Profile.active.verified.facial_match.
where('verified_at <= ?', report_date.end_of_day).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the verified scope on the prior line redundant with this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it can't be active without verified so idk why I am the way that I am.

distinct.
pluck(:initiating_service_provider_issuer)
end
end
end
end