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

PC-1463: Improve UX for when no address found #410

Merged
merged 8 commits into from
Dec 13, 2024

Conversation

samyou-softwire
Copy link
Contributor

@samyou-softwire samyou-softwire commented Dec 4, 2024

Link to Jira ticket

Description

adds routing logic to send directly to address manual if no addresses are found

also adds extra logic on the address page to check whether it will find any addresses. this does mean that each flow that uses OS API will send twice the number of requests. if this is too undesirable then can look into caching the result here

Checklist

  • I have made any necessary updates to the documentation
  • I have checked there are no unnecessary IDE warnings in this PR
  • I have checked there are no unintentional line ending changes
  • I have added tests where applicable
  • If I have made any changes to the code, I have used the IDE auto-formatter on it
  • If I have made any changes to Python files (even if not changing any content strings), I have run make extract-translations
  • If I have made any changes to website flow, I have updated the Flow Miro Board
  • If I have made any changes to website flow, I have checked forward and back behaviour is still consistent

Screenshots

image
image

@samyou-softwire samyou-softwire self-assigned this Dec 4, 2024
@samyou-softwire samyou-softwire force-pushed the PC-1463-improve-ux-for-no-address-found branch from 55d1d46 to 57f2031 Compare December 4, 2024 15:33
@@ -13,6 +13,22 @@ <h1 class="govuk-heading-l">
{{_("What is the property's address?")}}
</h1>
</legend>

{% if show_address_manually_error %}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this isn't an error in the normal sense in GBIS (it has no linked field, is not a validation error) so decided to add a specific case here rather than trying to extend the error showing logic

@samyou-softwire samyou-softwire force-pushed the PC-1463-improve-ux-for-no-address-found branch 2 times, most recently from eb6db71 to cf829d9 Compare December 5, 2024 10:36
@@ -2032,41 +2031,6 @@ def test_on_epc_select_page_enter_manually_can_be_selected():
assert page.has_one('h1:contains("What is the property\'s address?")')


@unittest.mock.patch("help_to_heat.frontdoor.interface.EPCApi", MockNotFoundEPCApi)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this test is no longer meaningful; the user no longer needs to click the select manual link

Copy link
Contributor

@jdgage jdgage left a comment

Choose a reason for hiding this comment

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

I'm puzzled by the whole approach: we call the API to check the number of results, then set a flag in the session, then immediately read from that flag again to determine the next page - have I got that right? Why do we need that extra machinery? Can we not pass values through to navigation without saving them to the session?

Comment on lines 651 to 658
check_address_has_results_in_address_api()
else:
data[address_choice_field] = address_choice_field_write_address
check_address_has_results_in_address_api()
except Exception as e: # noqa: B902
logger.exception(f"An error occurred: {e}")
data[address_choice_field] = address_choice_field_epc_api_fail
check_address_has_results_in_address_api()
Copy link
Contributor

Choose a reason for hiding this comment

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

Doing this feels brittle. I think I'd rather have one call after the try-catch. I don't follow why we don't call it in the one branch - why's that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in some cases we don't care for what the OS API response is, the only case being if the epc api returns results. could rewrite the logic to include just one call by checking afterwards

@samyou-softwire samyou-softwire force-pushed the PC-1463-improve-ux-for-no-address-found branch from cf829d9 to ab1f9bd Compare December 6, 2024 15:49
Copy link
Contributor

@jdgage jdgage left a comment

Choose a reason for hiding this comment

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

Another general approach point: are we now making an API call to check how many results, then throwing it away and making the exact same API call on the next page? That feels silly - it's worth interrogating why we can't just fetch the list once.

Comment on lines 652 to 656
will_use_os_api = (
data[address_choice_field] == address_choice_field_epc_api_fail
or country == country_field_scotland
and data[address_choice_field] == address_choice_field_write_address
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we now re-implementing logic from above (which could be equally brittle)? This is why I'd consider returning early in the case(s) where we don't want to do it.

@samyou-softwire
Copy link
Contributor Author

Another general approach point: are we now making an API call to check how many results, then throwing it away and making the exact same API call on the next page? That feels silly - it's worth interrogating why we can't just fetch the list once.

this is something that I think is possible and there is time to do; can look into tweaking this to request the os api just the one time

@samyou-softwire samyou-softwire force-pushed the PC-1463-improve-ux-for-no-address-found branch from ab1f9bd to 08deb05 Compare December 9, 2024 12:32
as well as respective tests, including this new route into flow generators
@samyou-softwire samyou-softwire force-pushed the PC-1463-improve-ux-for-no-address-found branch from 08deb05 to 041dce9 Compare December 9, 2024 12:34
@samyou-softwire
Copy link
Contributor Author

@jdgage this should be ready for re-review now, code now only makes one api call, & the logic should be less brittle (no more re-expression)

@samyou-softwire samyou-softwire force-pushed the PC-1463-improve-ux-for-no-address-found branch from 041dce9 to f585966 Compare December 9, 2024 13:48
@jdgage
Copy link
Contributor

jdgage commented Dec 9, 2024

This looks better: still refer back to the first comment: why do we need this intermediate field that we write to and then immediately read from?

@samyou-softwire
Copy link
Contributor Author

I'm puzzled by the whole approach: we call the API to check the number of results, then set a flag in the session, then immediately read from that flag again to determine the next page - have I got that right? Why do we need that extra machinery? Can we not pass values through to navigation without saving them to the session?

in general this is our mechanism for sending information to navigation, saving to session makes the routing reproducible. it's not too different from saving the answer to session and immediately querying that

@jdgage
Copy link
Contributor

jdgage commented Dec 10, 2024

in general this is our mechanism for sending information to navigation, saving to session makes the routing reproducible. it's not too different from saving the answer to session and immediately querying that

Sure. I think the reason it feels weird is that we've got these 'navigation-only' fields all together with actual user input fields? Can we make the distinction clearer?

@samyou-softwire samyou-softwire force-pushed the PC-1463-improve-ux-for-no-address-found branch from f585966 to a15074b Compare December 11, 2024 12:08
@samyou-softwire
Copy link
Contributor Author

in general this is our mechanism for sending information to navigation, saving to session makes the routing reproducible. it's not too different from saving the answer to session and immediately querying that

Sure. I think the reason it feels weird is that we've got these 'navigation-only' fields all together with actual user input fields? Can we make the distinction clearer?

have renamed these as 'journey fields' to make the distinction clearer

@@ -149,7 +149,9 @@
address_choice_field_enter_manually = "enter manually"
address_building_name_or_number_field = "building_name_or_number"
address_postcode_field = "postcode"
address_all_address_and_lmk_details_field = "address_and_lmk_details"
# PC-1463: removed lmk from field name as it stores info from both flows (lmk & uprn)
Copy link
Contributor

Choose a reason for hiding this comment

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

Commit message should have the ticket number, so don't need that here. Otherwise I think it's missing half of the why: why does the value still refer to 'LMK'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changing the value would mean the key used in the users' session would change and we'd need to consider not breaking existing sessions. the constant name can change for free. I think it's fine for a small semantic change here, though if we'd rather change the value too can look into that

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that's fine, but the comment should say this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

have updated this

address_all_address_and_lmk_details_field = "address_and_lmk_details"
# PC-1463: removed lmk from field name as it stores info from both flows (lmk & uprn)
address_all_address_and_details_field = "address_and_lmk_details"
address_no_results_field = "no_results" # yes/no options
Copy link
Contributor

Choose a reason for hiding this comment

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

What are these comments adding?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#yes/no options just to mark that that field takes a yes or a no. can go and update the rest of such fields to the same effect

@jdgage
Copy link
Contributor

jdgage commented Dec 11, 2024

Some comments about comments, otherwise all fine

@samyou-softwire samyou-softwire force-pushed the PC-1463-improve-ux-for-no-address-found branch from a15074b to 3898568 Compare December 12, 2024 11:11
@samyou-softwire samyou-softwire force-pushed the PC-1463-improve-ux-for-no-address-found branch from 3898568 to 4ddd68b Compare December 13, 2024 11:02
@samyou-softwire samyou-softwire force-pushed the PC-1463-improve-ux-for-no-address-found branch from 4ddd68b to 0c27ae9 Compare December 13, 2024 11:34
@jdgage
Copy link
Contributor

jdgage commented Dec 13, 2024

This is good to go

@samyou-softwire samyou-softwire merged commit fbb2380 into develop Dec 13, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants