Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit data publication to submitted applications #2207

Merged
merged 1 commit into from
May 16, 2024
Merged
Changes from all 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
19 changes: 7 additions & 12 deletions app/lib/analytics/publication_extract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,36 +61,31 @@ def countries
Country.all.sort_by { |country| CountryName.from_country(country) }
end

def application_forms(country)
ApplicationForm.joins(region: :country).where(region: { country: })
end

def submitted_application_forms(country)
application_forms(country).where(
"DATE(submitted_at) BETWEEN ? AND ?",
start_date,
end_date,
)
ApplicationForm
.joins(region: :country)
.where(region: { country: })
.where("DATE(submitted_at) BETWEEN ? AND ?", start_date, end_date)
end

def awarded_application_forms(country)
application_forms(country).where(
submitted_application_forms(country).where(
"DATE(awarded_at) BETWEEN ? AND ?",
start_date,
end_date,
)
end

def declined_application_forms(country)
application_forms(country).where(
submitted_application_forms(country).where(
"DATE(declined_at) BETWEEN ? AND ?",
start_date,
end_date,
)
end

def withdrawn_application_forms(country)
application_forms(country).where(
submitted_application_forms(country).where(
"DATE(withdrawn_at) BETWEEN ? AND ?",
start_date,
end_date,
Expand Down
Loading