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

1871: Cleaned status code in model #882

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
Open

Conversation

richardbored
Copy link
Collaborator

No description provided.

@richardbored richardbored requested a review from ahernp January 8, 2025 17:33
Copy link
Collaborator

@ahernp ahernp left a comment

Choose a reason for hiding this comment

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

The tests are failing because cases/models.py contains conflicts:

image

As there is no information in the Trello card or PR explaining what this change is trying to achieve, I cannot tell if the code changes have worked.

Also, there need to be new automated tests to cover the new logic.

if self.no_contact_four_week_chaser_sent_date is not None:
return self.no_contact_four_week_chaser_sent_date + timedelta(days=ONE_WEEK_IN_DAYS)

return date(1970, 1, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The value returned by this function may be returned by next_action_due_date below which itself can return None. I don't know why this function returns a magic date instead of None.

return (
self.case.enforcement_body_pursuing == Case.EnforcementBodyPursuing.YES_IN_PROGRESS
or self.case.enforcement_body_closed_case == Case.EnforcementBodyClosedCase.IN_PROGRESS
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see the benefit of turning if statement conditions into functions which return booleans. Unless they are being reused, which is not the case here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It splits up the code into something easier to understand but there is also the vague idea to use these in other ways

Copy link
Collaborator

Choose a reason for hiding this comment

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

The problem is that I think it makes the code more difficult to understand. These conditions make no sense in isolation, they only identify a Client status when they occur at specific positions inside the chain of if...elifs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I hadn't noticed that you had amended some of the conditions to calculate when statuses had been completed for reuse on the Status overflow page. I am not sure that the needs of that page should be driving how Case status itself is calculated. It feels a bit like the tail wagging the dog!

@richardbored richardbored requested a review from ahernp January 9, 2025 16:08
Copy link
Collaborator

@ahernp ahernp left a comment

Choose a reason for hiding this comment

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

The Unit Tests are still failing. You haven't written new unit tests for each of your new methods.

The rule of thumb I have followed when developing the platform is that any bespoke code needs a specific test added to the unit test suite. Also, this provides a degree of self documenting code. The tests should illustrate the set of expected behaviours.

@richardbored richardbored requested a review from ahernp January 10, 2025 17:55

if (
self.status.status == CaseStatus.Status.REPORT_READY_TO_SEND
and self.contact_details_found == Case.ContactDetailsFound.NOT_FOUND
):
if (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Case.contact_details_found is never updated in the platform. Its default value is ContactDetailsFound.NOT_CHECKED so the above condition is never met.

This field is also checked in notifications/utils.py when looking for overdue Cases. This is the cause of the original issue reported by the user.

If this pull request is not seeking to address the issue then is there another Trello card somewhere to do so?


for key, status in status_dict.items():
if status is False:
return key
Copy link
Collaborator

Choose a reason for hiding this comment

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

I hadn't noticed that the status is returned when for the first _status_complete check which fails.

That being the case, it is not obvious how to make the code more readable.

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