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

AB#241235: add ! push data to HOPE core #45

Merged
merged 5 commits into from
Mar 20, 2025
Merged

Conversation

vitali-yanushchyk-valor
Copy link
Collaborator

Legal Boilerplate

Look, I get it.
Contributing to HOPE Workspace, I retain all rights, title and interest in and to my contributions, and by keeping
this boilerplate intact I confirm that HOPE Workspace can use, modify, copy, and redistribute my contributions,
under HOPE's choice of terms.

@vitali-yanushchyk-valor vitali-yanushchyk-valor force-pushed the feature/post2hope branch 2 times, most recently from 7b6430d to 2c2f794 Compare March 12, 2025 13:26
Copy link

codecov bot commented Mar 12, 2025

Codecov Report

Attention: Patch coverage is 92.69663% with 13 lines in your changes missing coverage. Please review.

Project coverage is 92.40%. Comparing base (d0f938f) to head (849a197).
Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
...try_workspace/workspaces/admin/cleaners/actions.py 47.05% 9 Missing ⚠️
src/country_workspace/contrib/hope/push.py 96.22% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #45      +/-   ##
===========================================
+ Coverage    91.18%   92.40%   +1.22%     
===========================================
  Files          151      152       +1     
  Lines         4320     4466     +146     
  Branches       369      389      +20     
===========================================
+ Hits          3939     4127     +188     
+ Misses         283      236      -47     
- Partials        98      103       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ntrncic ntrncic requested a review from saxix March 12, 2025 14:53
@vitali-yanushchyk-valor vitali-yanushchyk-valor marked this pull request as ready for review March 12, 2025 14:54
@vitali-yanushchyk-valor vitali-yanushchyk-valor force-pushed the feature/post2hope branch 4 times, most recently from c2e94f7 to f614929 Compare March 17, 2025 14:29
@domdinicola
Copy link
Collaborator

@vitali-yanushchyk-valor pls resolve conflicts


def __post_init__(self) -> None:
"""Initialize the base path for API requests."""
self.base_path = f"{self.co_slug}/rdi/"
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not using init?

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's dataclass

"""Initialize the base path for API requests."""
self.base_path = f"{self.co_slug}/rdi/"

def validate_households(self) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't we have this in another place and call it? looks to me duplicated code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function only validates the selected beneficiaries, without updating last_checked and add a new version.

"""
try:
with transaction.atomic():
households = list(CountryHousehold.objects.filter(id__in=successful_ids))
Copy link
Collaborator

Choose a reason for hiding this comment

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

why converting it in list?


"""
processor = PushProcessor(
queryset=CountryHousehold.objects.filter(pk__in=job.config["pks"]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

would we have problems with large datasets?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed it.

# NEVER CHANGE THIS VALUES
HOUSEHOLD_CHECKER_NAME = "HOPE Household core"
INDIVIDUAL_CHECKER_NAME = "HOPE Individual core"
HOUSEHOLD_CHECKER_NAME: Final[str] = "HOPE Household checker"
Copy link
Collaborator

Choose a reason for hiding this comment

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

core checker & also for individaul

Copy link
Collaborator

Choose a reason for hiding this comment

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

@vitali-yanushchyk-valor vitali-yanushchyk-valor force-pushed the feature/post2hope branch 2 times, most recently from 51f2d42 to e38ae85 Compare March 18, 2025 14:36
@domdinicola
Copy link
Collaborator

@vitali-yanushchyk-valor fix tests pls

@vitali-yanushchyk-valor vitali-yanushchyk-valor changed the title add ! push data to HOPE core AB#241235: add ! push data to HOPE core Mar 20, 2025
# NEVER CHANGE THIS VALUES
HOUSEHOLD_CHECKER_NAME = "HOPE Household core"
INDIVIDUAL_CHECKER_NAME = "HOPE Individual core"
HOUSEHOLD_CHECKER_NAME: Final[str] = "HOPE Household checker"
Copy link
Collaborator

Choose a reason for hiding this comment

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

hh_fs.fields.get_or_create(name="consent", attrs={"required": False, "label": "Consent"}, definition=_bool)
hh_fs.fields.get_or_create(name="consent_sharing", definition=_bool)
hh_fs.fields.get_or_create(name="country_origin", definition=_char)
hh_fs.fields.get_or_create(name="first_registration_date", attrs={"label": "First Registration"}, definition=_date)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why we removed this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

datachecker changes follow the current HOPE core.

  • consent_sharing - is not bool - it's ConsentSharingEnum and when I asked about it at the sync, I got an answer, that we will not use it.
  • country_origin - I declared to use CountryChoice
  • first_registration_date at the HOPE core is defined like serializers.DateTimeField(default=timezone.now)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated the system to require full_name, birth_date, and relationship too, since HOPE core will respond with an error if they are not provided.

This is one of the questions I wanted to clarify. We have a base fieldset, and in CW we can create additional fieldsets that extend existing. Since this is the very first commit regarding data push to HOPE core —and we don't yet have such a process in production—I modified the default datachecker in accordance with the current requirements from HOPE core. In the future, this mechanism for creating new fieldsets can be utilized.
Of course, if the base datachecker is meant to remain exactly as it was before my changes, I can revert them.

_h_residence = FieldDefinition.objects.get(slug="hope-hh-residencestatus")
_i_gender = FieldDefinition.objects.get(slug="hope-ind-gender")
_i_disability = FieldDefinition.objects.get(slug="hope-ind-disability")
_i_role = FieldDefinition.objects.get(slug="hope-ind-role")
_i_relationship = FieldDefinition.objects.get(slug="hope-ind-relationship")

hh_fs, __ = Fieldset.objects.get_or_create(name=HOUSEHOLD_CHECKER_NAME)
hh_fs.fields.get_or_create(name="address", attrs={"label": "Address", "required": True}, definition=_char)
hh_fs.fields.get_or_create(name="address", definition=_char)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why was this changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

because currently address in not mandatory at the HOPE core side.

@domdinicola domdinicola merged commit 22ef82c into develop Mar 20, 2025
28 checks passed
@vitali-yanushchyk-valor vitali-yanushchyk-valor deleted the feature/post2hope branch March 26, 2025 06:18
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