Skip to content

Commit 525c9e5

Browse files
Karthikeyannhsdependabot[bot]oneeb-nhsrobbailiff2
committed
Eli 615 : fix - multi campaign target collision (#593)
* ELI-615 | campaign having recent - active start_date supersedes the others sharing same best-status * ELI-615 | more linting * ELI-615 | revert commit * ELI-615 | wip * ELI-615 | wip * ELI-615 | wip * Bump werkzeug from 3.1.5 to 3.1.6 Bumps [werkzeug](https://github.com/pallets/werkzeug) from 3.1.5 to 3.1.6. - [Release notes](https://github.com/pallets/werkzeug/releases) - [Changelog](https://github.com/pallets/werkzeug/blob/main/CHANGES.rst) - [Commits](pallets/werkzeug@3.1.5...3.1.6) --- updated-dependencies: - dependency-name: werkzeug dependency-version: 3.1.6 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Updated not_member_of operator to NotMemberOf (#594) * Added vulture to workflows (#585) * Added vulture to workflows * Added new make commands and added to project * Added updated lockfile * Minimal config with no errors * Corrected vulture commands * Generating new lock file * ELI-615 | modified iterations_result to iteration result * ELI-615 | fix - naming issues | handle stop iter exception * ELI-615 | campaign_configs - fixture updated | test case fixed * ELI-615 | fix flaky tests do to fixture scope * ELI-615 | fix flaky tests - removed best status test * ELI-615 | used raw campagin config for tests using iteration dates * ELI-615 | fix - campaign group is used correctly * ELI-615 | fix test_campaigns_grouped_by_condition_name_filters_correctly * ELI-615 | fix tests * ELI-615 | linting * ELI-615 | renamed best_iteration_result to iteration_result_summary * ELI-615 | add more test cases - it tests * ELI-615 | test commit - try git leaks ignore * ELI-615 | incorporated review comments --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: oneeb-nhs <258801025+oneeb-nhs@users.noreply.github.com> Co-authored-by: Robert Bailiff <rob.bailiff1@nhs.net>
1 parent c81afdd commit 525c9e5

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

.gitleaksignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# SEE: https://github.com/gitleaks/gitleaks/blob/master/README.md#gitleaksignore
22

33
cd9c0efec38c5d63053dd865e5d4e207c0760d91:docs/guides/Perform_static_analysis.md:generic-api-key:37
4+
45
bf0c77098978c450d8570b38fb480fbb8d6a0628:.github/instructions/*.instructions.md:stripe-access-token:140

src/eligibility_signposting_api/services/processors/campaign_evaluator.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get_campaign_with_latest_iteration(self, active_campaigns: list[CampaignConf
3131

3232
for cc in active_campaigns:
3333
try:
34-
valid_items.append((cc.current_iteration.iteration_datetime, cc))
34+
valid_items.append((cc.current_iteration.iteration_date, cc))
3535
except StopIteration:
3636
logger.info(
3737
"Skipping campaign ID %s as no active iteration was found.",
@@ -41,15 +41,13 @@ def get_campaign_with_latest_iteration(self, active_campaigns: list[CampaignConf
4141
if not valid_items:
4242
latest_campaign = None
4343
else:
44-
max_date_time = max(item[0] for item in valid_items)
45-
cc_with_max_iteration_date: list[CampaignConfig] = [
46-
item[1] for item in valid_items if item[0] == max_date_time
47-
]
44+
max_date = max(item[0] for item in valid_items)
45+
cc_with_max_iteration_date: list[CampaignConfig] = [item[1] for item in valid_items if item[0] == max_date]
4846
if len(cc_with_max_iteration_date) > 1:
4947
err_msg = (
5048
f"Ambiguous result: '{len(cc_with_max_iteration_date)}' active iterations "
5149
f"for target {cc_with_max_iteration_date[0].target} "
52-
f"found for datetime '{max_date_time}' "
50+
f"found for date '{max_date}' "
5351
f"across campaign(s) {[cc.id for cc in cc_with_max_iteration_date]}"
5452
)
5553
raise ValueError(err_msg)

tests/integration/in_process/test_eligibility_endpoint.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@
3333
from tests.integration.conftest import UNIQUE_CONSUMER_HEADER
3434

3535

36-
def today() -> date:
36+
def today():
3737
return datetime.now(UTC).date()
3838

3939

40-
def yesterday() -> date:
40+
def yesterday():
4141
return datetime.now(UTC).date() - timedelta(days=1)
4242

4343

44-
def tomorrow() -> date:
44+
def tomorrow():
4545
return datetime.now(UTC).date() + timedelta(days=1)
4646

4747

@@ -1532,10 +1532,11 @@ def test_if_multiple_active_iterations_with_same_iteration_datetime_for_the_same
15321532
)
15331533
),
15341534
)
1535+
15351536
err_msg = (
15361537
"Ambiguous result: '2' active iterations "
15371538
"for target RSV "
1538-
f"found for datetime '{previous_day} 00:00:00+00:00' "
1539+
f"found for date '{previous_day}' "
15391540
"across campaign(s) ['RSV_campaign_id_1', 'RSV_campaign_id_2']"
15401541
)
15411542
assert any(err_msg in message for message in caplog.messages), (

0 commit comments

Comments
 (0)