Add method to quickly test for AnnualReport account eligibility (#37045)

This commit is contained in:
Claire 2025-11-28 17:19:23 +01:00 committed by GitHub
parent 92278796c3
commit 801672e3cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 0 deletions

View File

@ -23,6 +23,12 @@ class AnnualReport
@year = year
end
def eligible?
with_read_replica do
SOURCES.all? { |klass| klass.new(@account, @year).eligible? }
end
end
def generate
return if GeneratedAnnualReport.exists?(account: @account, year: @year)

View File

@ -12,6 +12,10 @@ class AnnualReport::Source
raise NotImplementedError
end
def eligible?
true
end
protected
def report_statuses

View File

@ -15,6 +15,10 @@ class AnnualReport::TopHashtags < AnnualReport::Source
}
end
def eligible?
report_statuses.joins(:tags).exists?
end
private
def top_hashtags

View File

@ -11,6 +11,10 @@ class AnnualReport::TopStatuses < AnnualReport::Source
}
end
def eligible?
report_statuses.public_visibility.exists?
end
private
def status_identifier(status)