Skip to content

Commit

Permalink
Merge pull request #4410 from unicef/master-to-stg
Browse files Browse the repository at this point in the history
Merge master to staging
  • Loading branch information
domdinicola authored Nov 6, 2024
2 parents 188075e + afd71b1 commit cd2f1dd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function RegistrationDetails({
const { t } = useTranslation();
const { data } = useRegistrationDataImportQuery({
variables: {
id: btoa(`RegistrationDataImportNode:${hctId}`),
id: hctId,
},
});
if (!data) {
Expand Down
16 changes: 11 additions & 5 deletions src/hct_mis_api/apps/program/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from hct_mis_api.apps.core.utils import (
chart_filters_decoder,
chart_permission_decorator,
decode_id_string,
get_program_id_from_headers,
to_choice_object,
)
from hct_mis_api.apps.payment.filters import (
Expand Down Expand Up @@ -261,13 +261,19 @@ class Query(graphene.ObjectType):
is_deduplication_disabled = graphene.Boolean()

def resolve_can_run_deduplication(self, info: Any, **kwargs: Any) -> bool:
encoded_program_id = info.context.headers.get("Program")
program = Program.objects.only("biometric_deduplication_enabled").get(id=decode_id_string(encoded_program_id))
program_id = get_program_id_from_headers(info.context.headers)
if not program_id:
return False

program = Program.objects.only("biometric_deduplication_enabled").get(id=program_id)
return program.biometric_deduplication_enabled

def resolve_is_deduplication_disabled(self, info: Any, **kwargs: Any) -> bool:
encoded_program_id = info.context.headers.get("Program")
program = Program.objects.only("id").get(id=decode_id_string(encoded_program_id))
program_id = get_program_id_from_headers(info.context.headers)
if not program_id:
return True

program = Program.objects.only("id").get(id=program_id)
# deduplication engine in progress
is_still_processing = RegistrationDataImport.objects.filter(
program=program,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def __init__(
super().__init__()

def _handle_image_field(self, value: Any, is_flex_field: bool) -> Optional[Union[str, File]]:
logger.info(f"Processing image field: {value}")
if not self.registration_data_import.pull_pictures:
return None
if self.attachments is None:
Expand All @@ -102,6 +103,7 @@ def _handle_image_field(self, value: Any, is_flex_field: bool) -> Optional[Union
file = File(image_bytes, name=value)
if is_flex_field:
return default_storage.save(value, file)
logger.info(f"Image field processed: {value}")
return file

def _handle_geopoint_field(self, value: Any, is_flex_field: bool) -> Point:
Expand Down Expand Up @@ -221,10 +223,14 @@ def execute(
collectors_to_create = defaultdict(list)
household_hash_list = []
household_batch_size = 50
logger.info(f"Processing {len(self.reduced_submissions)} households")
chunk_index = 0
delivery_mechanism_xlsx_fields = PendingDeliveryMechanismData.get_scope_delivery_mechanisms_fields(
by="xlsx_field"
)
for reduced_submission_chunk in chunks(self.reduced_submissions, household_batch_size):
chunk_index += 1
logger.info(f"Processing chunk {chunk_index}/{len(self.reduced_submissions) // household_batch_size}")
for household in reduced_submission_chunk:
# AB#199540
household_hash = calculate_hash_for_kobo_submission(household)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ def create_household_data(
flex_fields = household_payload.pop("flex_fields", dict())

flex_fields.update(**self.get_extra_ff(mapping.get("flex_fields", list()), record_data_dict))
individuals_key = mapping["defaults"].get("individuals_key", "individuals")
household_data = {
**household_payload,
# "flex_registrations_record": record,
Expand All @@ -215,7 +214,6 @@ def create_household_data(
"country": str(Country.objects.get(iso_code2=mapping["defaults"][COUNTRY]).pk),
"consent": True,
"collect_individual_data": YES,
"size": len(record_data_dict[individuals_key]),
"flex_fields": flex_fields,
}
return self._create_object_and_validate(household_data, PendingHousehold)
Expand Down Expand Up @@ -353,7 +351,6 @@ def create_household_for_rdi_household(self, record: Any, registration_data_impo
mapping,
)

household.size = len(individuals)
if head:
household.head_of_household = head

Expand All @@ -366,6 +363,7 @@ def create_household_for_rdi_household(self, record: Any, registration_data_impo
individual=sec_collector, household=household, role=ROLE_ALTERNATE
)

household.registration_id = record.source_id
household.registration_id = record.source_id # TODO to be removed
household.detail_id = record.source_id
household.save()
record.mark_as_imported()

0 comments on commit cd2f1dd

Please sign in to comment.