Skip to content

Conversation

@pm-dimagi
Copy link
Contributor

@pm-dimagi pm-dimagi commented Mar 31, 2025

Product Description

-bug fixes
expired opportunity bug fix
non connect user workflow
and continue button in recovery flow
https://dimagi.atlassian.net/browse/CCCT-890
https://dimagi.atlassian.net/browse/CCCT-900

Safety Assurance

Safety story

Describe:

  • tested the changes in dev testing

In particular consider how existing data may be impacted by this change.
cross-request: dimagi/commcare-core#1455

Labels and Review

  • Do we need to enhance the manual QA test coverage ? If yes, the "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, the "Release Note" label is set and a "Release Note" is specified in PR description.
  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@coderabbitai
Copy link

coderabbitai bot commented Mar 31, 2025

📝 Walkthrough

Walkthrough

The pull request modifies the control flow in several components. In the ConnectJobRecord class, the JSON parsing logic is adjusted so that a job is considered active by default unless the JSON explicitly specifies that it is inactive. In both the ConnectAppDatabaseUtil and ConnectJobUtils classes, a guard clause is added to check whether the Connect ID is configured before attempting any database access, returning null if not configured. In the ConnectIDSignupFragment, the phone number verification process has been reorganized: the switch-case structure has been refined, the handling of success and failure callbacks for checking phone availability via the API has been updated, and error feedback is now set with revised text depending on whether the context is a recovery scenario or not.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant DatabaseUtil
  participant ConnectManager
  participant Database

  Caller->>DatabaseUtil: Request app data/record
  DatabaseUtil->>ConnectManager: isConnectIdConfigured()?
  alt Connect ID Configured
    ConnectManager-->>DatabaseUtil: true
    DatabaseUtil->>Database: Fetch record
    Database-->>DatabaseUtil: Record data
    DatabaseUtil-->>Caller: Return record
  else Not Configured
    ConnectManager-->>DatabaseUtil: false
    DatabaseUtil-->>Caller: Return null
  end
Loading
sequenceDiagram
  participant User
  participant SignupFragment
  participant ApiConnectId
  participant ErrorTextView

  User->>SignupFragment: Trigger phone check
  SignupFragment->>ApiConnectId: checkPhoneAvailable(phoneNumber)
  alt Success Response
      ApiConnectId-->>SignupFragment: Success response
      SignupFragment->>ErrorTextView: Set text "connect_phone_not_found" (recovery case)
  else Failure Response
      ApiConnectId-->>SignupFragment: Failure response (e.g., network/API error)
      SignupFragment->>ErrorTextView: Set/adjust error text and visibility
  end
Loading

Suggested labels

cross requested, skip-integration-tests

Suggested reviewers

  • OrangeAndGreen
  • avazirna
  • shubham1g5

📜 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 eee14c9 and b056ec6.

📒 Files selected for processing (4)
  • app/src/org/commcare/android/database/connect/models/ConnectJobRecord.java (1 hunks)
  • app/src/org/commcare/connect/database/ConnectAppDatabaseUtil.java (1 hunks)
  • app/src/org/commcare/connect/database/ConnectJobUtils.java (1 hunks)
  • app/src/org/commcare/fragments/connectId/ConnectIDSignupFragment.java (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
app/src/org/commcare/android/database/connect/models/ConnectJobRecord.java (1)
Learnt from: pm-dimagi
PR: dimagi/commcare-android#2847
File: app/src/org/commcare/android/database/connect/models/ConnectJobRecordV7.java:171-173
Timestamp: 2025-03-31T08:25:14.284Z
Learning: When migrating ConnectJobRecord from V4 to V7 using fromV4() method, isActive is intentionally defaulted to true for all migrated records.
🧬 Code Definitions (2)
app/src/org/commcare/connect/database/ConnectAppDatabaseUtil.java (1)
app/src/org/commcare/connect/database/ConnectDatabaseHelper.java (1)
  • ConnectDatabaseHelper (27-117)
app/src/org/commcare/connect/database/ConnectJobUtils.java (2)
app/src/org/commcare/connect/ConnectManager.java (1)
  • ConnectManager (86-1064)
app/src/org/commcare/connect/database/ConnectDatabaseHelper.java (1)
  • ConnectDatabaseHelper (27-117)
🔇 Additional comments (5)
app/src/org/commcare/connect/database/ConnectAppDatabaseUtil.java (1)

13-20: Added null check for Connect ID configuration

Good defensive programming - adding a check for ConnectManager.isConnectIdConfigured() before accessing the database prevents unnecessary database operations when the Connect ID isn't set up.

app/src/org/commcare/android/database/connect/models/ConnectJobRecord.java (1)

207-207: Revised job active state logic for expired opportunities bug fix

This change flips the default behavior for job activity - now jobs are considered active by default unless explicitly marked inactive in the JSON. This aligns with the retrieved learning about defaulting migrated records to active.

app/src/org/commcare/connect/database/ConnectJobUtils.java (1)

415-421: Added null check for Connect ID configuration

This matches the defensive pattern applied in ConnectAppDatabaseUtil. Good addition of ConnectManager.isConnectIdConfigured() check before accessing the database to avoid unnecessary database operations when the Connect ID isn't properly configured.

app/src/org/commcare/fragments/connectId/ConnectIDSignupFragment.java (2)

268-269: Improved switch-case structure using new Java syntax

Reorganized the switch-case to use modern Java syntax for combining multiple cases that have the same behavior. This makes the code more maintainable and readable.


281-337: Enhanced phone number verification with better error handling

The changes significantly improve error handling during phone number verification:

  1. For recovery flows, appropriate error messages are now shown
  2. Added dedicated handling for network failures and API version issues
  3. Improved navigation flow based on verification outcomes

This implementation addresses the non-connect user workflow issue mentioned in the PR description by providing clearer feedback and recovery paths.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@shubham1g5 shubham1g5 left a comment

Choose a reason for hiding this comment

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

Can we add Jira links to issues this PR is trying to solve for in PR description.

case ConnectConstants.CONNECT_REGISTRATION_PRIMARY_PHONE,
ConnectConstants.CONNECT_REGISTRATION_CHANGE_PRIMARY_PHONE,
ConnectConstants.CONNECT_RECOVERY_PRIMARY_PHONE -> {
if (existingPrimary != null && existingPrimary.equals(phone)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what are we trying to solve here ? And why is primary check not required any more ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it was a issue we are getting existing no when we are changing the method from signup to recover we pass the no entered there so this condition willl never allow user to check phone no

@shubham1g5
Copy link
Contributor

@pm-dimagi How about we PR this to master instead and then merge master inside connect_qa. I am not sure how else we will get these changes in master otherwise. Thoughts ?

@pm-dimagi
Copy link
Contributor Author

@shubham1g5 if we merge directly to master there are few files which are not present in the master code for now its in phase 2pr , we can take up these changes in phase 2pr

@pm-dimagi
Copy link
Contributor Author

@damagatchi retest this please

@pm-dimagi pm-dimagi requested a review from shubham1g5 April 1, 2025 15:48
@pm-dimagi pm-dimagi merged commit b5da6ff into connect_qa Apr 1, 2025
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Apr 16, 2025
@coderabbitai coderabbitai bot mentioned this pull request Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants