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

14.0 t0735 - fcp state not correct when suspension and reactivation lifecycle are on the same date #1844

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

auclerc
Copy link
Contributor

@auclerc auclerc commented Feb 14, 2024

No description provided.

@auclerc auclerc changed the base branch from 12.0 to 14.0 February 14, 2024 08:07
@ecino
Copy link
Member

ecino commented Feb 15, 2024

Your pull request should only contain the relevant commit. Could you please rebase your branch onto compassion/14.0 ?

Copy link
Member

@ecino ecino left a comment

Choose a reason for hiding this comment

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

Don't forget also to run "pre-commit" on your branch. In the modules directory you can type the command "pre-commit run -a".

Comment on lines 477 to 491
most_recent_date = max(project.lifecycle_ids.mapped('date'))
most_recent_lifecycles = project.lifecycle_ids.filtered(lambda r: r.date == most_recent_date)

# Check if there is a lifecyle with type 'Reactivation' in the most recent date
reactivation_lifecycle = next(
(lifecycle for lifecycle in most_recent_lifecycles if lifecycle.type == 'Reactivation'), None)

# If it exists, lifecycle with type 'Reactivation' is determinant
if reactivation_lifecycle is None:
determinant_lifecycle = most_recent_lifecycles[-1]
else:
determinant_lifecycle = reactivation_lifecycle
project.suspension = False

if determinant_lifecycle.type == "Suspension":
Copy link
Member

Choose a reason for hiding this comment

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

Lifecycle events are ordered by date from most recent to oldest. I would suggest it like this to make it shorter.

Suggested change
most_recent_date = max(project.lifecycle_ids.mapped('date'))
most_recent_lifecycles = project.lifecycle_ids.filtered(lambda r: r.date == most_recent_date)
# Check if there is a lifecyle with type 'Reactivation' in the most recent date
reactivation_lifecycle = next(
(lifecycle for lifecycle in most_recent_lifecycles if lifecycle.type == 'Reactivation'), None)
# If it exists, lifecycle with type 'Reactivation' is determinant
if reactivation_lifecycle is None:
determinant_lifecycle = most_recent_lifecycles[-1]
else:
determinant_lifecycle = reactivation_lifecycle
project.suspension = False
if determinant_lifecycle.type == "Suspension":
last_info = project.lifecycle_ids[0]
reactivation_lifecycle = project.lifecycle_ids.filtered(lambda r: r.date == last_info.date and r.type == "Reactivation")
# If it exists, lifecycle with type 'Reactivation' is determinant
determinant_lifecycle = reactivation_lifecycle or last_info
if determinant_lifecycle.type == "Suspension":

Copy link

sonarcloud bot commented Feb 21, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

idea Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

@auclerc auclerc requested a review from ecino February 21, 2024 11:31
@ecino ecino merged commit b08d603 into CompassionCH:14.0 Mar 7, 2024
0 of 2 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