-
Notifications
You must be signed in to change notification settings - Fork 51
T2240 no money hold extension reminders #2066
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
Conversation
Summary of ChangesHello @ecino, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces targeted improvements to the system's notification mechanisms and document generation. It ensures that 'no money hold' extension reminders are triggered only for the relevant hold type and standardizes the order of images when creating correspondence, leading to more accurate and consistent output. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
df8c81f to
093dacd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request aims to limit 'no money hold' extension reminders to only apply to holds of type NO_MONEY_HOLD. The changes in sbc_compassion/models/correspondence_s2b_generator.py to sort images by reverse order seem correct and improve consistency. The main logic change in child_compassion/models/compassion_hold.py correctly implements the desired behavior for notifications. However, it introduces a duplicated conditional check, which impacts code clarity and maintainability. I've left a comment with a suggestion to refactor this for better code quality.
| if hold.type == HoldType.NO_MONEY_HOLD.value: | ||
| if hold.child_id.sponsor_id: | ||
| body = ( | ||
| "The no money hold for child {local_id} was expiring on " | ||
| "{old_expiration} and was extended to {new_expiration} " | ||
| "({extension_description} extension).{additional_text}" | ||
| ) | ||
| hold.message_post( | ||
| body=_(body.format(**values)), | ||
| subject=_("No money hold extension"), | ||
| subtype_xmlid="mail.mt_comment", | ||
| ) | ||
| else: | ||
| body = _( | ||
| "The no money hold for child {local_id} is expiring on " | ||
| "{old_expiration} and will not be extended since " | ||
| "no sponsorship exists for this child." | ||
| ) | ||
| hold.message_post(body=body.format(**values)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change correctly restricts notifications to NO_MONEY_HOLD types. However, it introduces a duplicated check for hold.child_id.sponsor_id (first at line 479, then again at line 493). This makes the code less efficient and harder to maintain.
Consider refactoring the postpone_no_money_hold method to avoid this duplication. A better structure would be:
if hold.child_id.sponsor_id: # Check that a sponsorship exists
# ... (logic to extend the hold)
hold.write(hold_vals)
if hold.type == HoldType.NO_MONEY_HOLD.value:
body = (
"The no money hold for child {local_id} was expiring on "
"{old_expiration} and was extended to {new_expiration} "
"({extension_description} extension).{additional_text}"
)
hold.message_post(
body=_(body.format(**values)),
subject=_("No money hold extension"),
subtype_xmlid="mail.mt_comment",
)
else:
if hold.type == HoldType.NO_MONEY_HOLD.value:
body = _(
"The no money hold for child {local_id} is expiring on "
"{old_expiration} and will not be extended since "
"no sponsorship exists for this child."
)
hold.message_post(body=body.format(**values))This would require restructuring the logic starting from line 479.
No description provided.