Skip to content

Commit b7ae006

Browse files
fix: set deduplication_status in bulk SQL insert, remove inaccurate docstring return
Include deduplication_status='new' in the program membership raw SQL INSERT to match ORM default. Remove misleading :return: docstring from _add_beneficiaries (method returns None).
1 parent 931f5a3 commit b7ae006

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

spp_programs/models/managers/cycle_manager_base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,6 @@ def _add_beneficiaries(self, cycle, beneficiaries, state="draft", do_count=False
838838
:param beneficiaries: List of partner IDs
839839
:param state: String state to be set to beneficiary
840840
:param do_count: Boolean - set to False to not run compute functions
841-
:return: Integer - count of inserted members
842841
"""
843842
today = fields.Date.today()
844843
vals_list = [

spp_programs/models/program_membership.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,14 @@ def _bulk_insert_on_conflict(self, vals_list, chunk_size=1000):
414414
for v in batch:
415415
state = v.get("state", "draft")
416416
enrollment_date = now if state == "enrolled" else None
417-
values.append("(%s, %s, %s, %s, %s, %s, now(), now())")
417+
values.append("(%s, %s, %s, %s, %s, %s, %s, now(), now())")
418418
params.extend(
419419
[
420420
v["partner_id"],
421421
v["program_id"],
422422
state,
423423
enrollment_date,
424+
v.get("deduplication_status", "new"),
424425
uid,
425426
uid,
426427
]
@@ -429,6 +430,7 @@ def _bulk_insert_on_conflict(self, vals_list, chunk_size=1000):
429430
sql = """
430431
INSERT INTO spp_program_membership
431432
(partner_id, program_id, state, enrollment_date,
433+
deduplication_status,
432434
create_uid, write_uid, create_date, write_date)
433435
VALUES {}
434436
ON CONFLICT (partner_id, program_id) DO NOTHING

0 commit comments

Comments
 (0)