Skip to content

Commit

Permalink
When applicant do not follow the form natural step order
Browse files Browse the repository at this point in the history
some user fill in the date-of-entry step before the start-date
and this caused a bug in the form analytic widget which assumed that
the form was filled in the order expected.

TODO: This type of behaviour could be used as a way to flag potential
fraud application.
  • Loading branch information
fumimowdan committed Oct 13, 2023
1 parent 042c6d7 commit 0baffa3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/models/form/eligibility_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def failure_reason
end

def date_of_entry_eligible?(date_of_entry, start_date)
return false unless date_of_entry && start_date

date_of_entry >= start_date - 3.months
end

Expand Down
2 changes: 1 addition & 1 deletion app/queries/forms_funnel_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def entry_date_step_query(required_field)

form_dates = date_of_entries.each_with_object([]) do |(id, date_of_entry), list|
entry = start_dates.detect { |(sid, _)| sid == id }
list << [date_of_entry.to_date, entry.last.to_date]
list << [date_of_entry.to_date, entry&.last&.to_date]
list
end

Expand Down

0 comments on commit 0baffa3

Please sign in to comment.