Skip to content

Conversation

@jjackson
Copy link
Member

This adds the org_pay_per_visit field to the data export serializer, allowing it to be included in opportunity data exports.

AI Generated by Cursor

This adds the org_pay_per_visit field to the data export serializer,
allowing it to be included in opportunity data exports.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 12, 2025

Walkthrough

Adds a new SerializerMethodField org_pay_per_visit to OpportunityDataExportSerializer in commcare_connect/data_export/serializer.py, registers it in the serializer Meta fields, and implements get_org_pay_per_visit(self, obj) which returns obj.org_pay_per_visit.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Change is limited to a single serializer file and is a straightforward field addition and accessor.
  • Review attention:
    • Ensure get_org_pay_per_visit handles missing/None values consistently with other serializer methods.
    • Confirm org_pay_per_visit is present on objects being serialized or documented behavior for absent attribute.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding a new org_pay_per_visit field to OpportunityDataExportSerializer.
Description check ✅ Passed The description directly relates to the changeset, explaining that the org_pay_per_visit field is added to enable it in opportunity data exports.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bef014d and ef30900.

📒 Files selected for processing (1)
  • commcare_connect/data_export/serializer.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
commcare_connect/data_export/serializer.py (1)
commcare_connect/opportunity/models.py (1)
  • org_pay_per_visit (100-101)
🪛 Ruff (0.14.5)
commcare_connect/data_export/serializer.py

34-34: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)


49-49: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)

🔇 Additional comments (3)
commcare_connect/data_export/serializer.py (3)

30-30: LGTM! Field declaration follows established pattern.

The SerializerMethodField declaration is consistent with other computed fields in this serializer (program, visit_count).


34-44: LGTM! Field correctly added to Meta.

The field is properly registered in the fields list, enabling it to be included in the serialized output.

Note: The static analysis hint (RUF012) about ClassVar annotation is a false positive—Meta.fields is a standard Django REST Framework pattern.


52-53: Implementation is correct—edge case properly handled.

The verification confirms the code is safe. The managed field is automatically set to True in ManagedOpportunity.__init__(), ensuring consistency between the flag and the relationship. The model property guards access with if self.managed, preventing any unsafe behavior.

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jjackson
Copy link
Member Author

@coderabbitai generate docstrings

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 12, 2025

✅ Actions performed

Initiated docstring generation; will generate only if new commits exist.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 12, 2025

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #841

coderabbitai bot added a commit that referenced this pull request Nov 12, 2025
…alizer-2aa4`

Docstrings generation was requested by @jjackson.

* #840 (comment)

The following files were modified:

* `commcare_connect/data_export/serializer.py`
@jjackson
Copy link
Member Author

I don't merge in directly so can you merge, thanks!

Copy link
Contributor

@hemant10yadav hemant10yadav left a comment

Choose a reason for hiding this comment

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

Looks like the CI/linter was failing. I recommend installing the git hook see the instructions here — that way you’ll see the linting errors before committing. I’ve already fixed it for this PR.

@hemant10yadav hemant10yadav merged commit dc284eb into dimagi:main Nov 18, 2025
3 checks passed
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.

3 participants