-
-
Notifications
You must be signed in to change notification settings - Fork 45
CCCT-2018 Parse Release Toggles During Start Configuration #3511
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
CCCT-2018 Parse Release Toggles During Start Configuration #3511
Conversation
Parsed feature release toggles from inside StartConfigurationResponseParser and stored the toggles in PersonalIdSessionData.
Stored feature release toggles in the Connect DB upon successful user account recovery.
…nto task/CCCT-2018-parse-release-toggles-when-start-configuration
Updated unit tests in StartConfigurationResponseParserTest. Added some null safety.
📝 WalkthroughWalkthroughThis PR adds support for feature release toggles in the CommCare Connect authentication flow. Changes include: adding a nullable Sequence DiagramsequenceDiagram
participant Server as Start Configuration<br/>API Server
participant Parser as StartConfiguration<br/>ResponseParser
participant Session as PersonalIdSessionData
participant Fragment as PersonalIdBackupCode<br/>Fragment
participant DB as ConnectAppDatabaseUtil
Server->>Parser: Return response with toggles JSON
Parser->>Parser: Parse toggles to List<ConnectReleaseToggleRecord>
Parser->>Session: Assign featureReleaseToggles
Fragment->>Session: Retrieve featureReleaseToggles
alt Toggles present
Fragment->>DB: storeReleaseToggles(toggles)
DB->>DB: Persist to database
else Toggles null
Fragment->>Fragment: Skip storage
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@app/src/org/commcare/connect/network/connectId/parser/StartConfigurationResponseParser.java`:
- Around line 33-38: The parser currently leaves the previous feature toggles
intact when the "toggles" field is omitted; update
StartConfigurationResponseParser so that when featureReleaseTogglesJson is null
you explicitly clear overwriting state by calling
sessionData.setFeatureReleaseToggles(...) with an empty list (instead of doing
nothing). Locate the block using featureReleaseTogglesJson,
ConnectReleaseToggleRecord.Companion.releaseTogglesFromJson and
sessionData.setFeatureReleaseToggles and add the else branch that sets an empty
list to avoid stale toggles persisting across parses.
app/src/org/commcare/connect/network/connectId/parser/StartConfigurationResponseParser.java
Outdated
Show resolved
Hide resolved
Cleared release toggles when null for the PersonalIdSessionData.
...ts/src/org/commcare/connect/network/connectId/parser/StartConfigurationResponseParserTest.kt
Show resolved
Hide resolved
app/src/org/commcare/fragments/personalId/PersonalIdBackupCodeFragment.java
Outdated
Show resolved
Hide resolved
Moved logic for storing release toggles to PersonalIdMessageFragment.
Tweaked ConnectReleaseToggleRecord so that the date fields are optional, and also reflected that in a new unit test.
app/src/org/commcare/connect/network/connectId/parser/StartConfigurationResponseParser.java
Outdated
Show resolved
Hide resolved
Added one more assertion to new unit test.
Abstracted some json logic to ConnectReleaseToggleRecord.releaseTogglesFromJson().
app/src/org/commcare/android/database/connect/models/ConnectReleaseToggleRecord.kt
Show resolved
Hide resolved
Added handling for the case that toggles are missing from response json.
CCCT-2018
Technical Summary
I added logic to parse release toggles for the
start_configurationAPI call.Important note - Since the Connect DB is not available during parsing for the
start_configurationAPI call, and theConnectReleaseTogglesParser.parse()function currently requires a response code and an input object, I opted to not reuse theConnectReleaseTogglesParserand instead parse the toggles separately inStartConfigurationResponseParserwhile storing the toggles in thePersonalIdSessionDatafor storage in the Connect DB later during successful user account recovery. Let me know if there is a better approach to take here.Edit: I tweaked
ConnectReleaseToggleRecordto treat the date fields as optional and added a new unit test for that accordingly.Safety Assurance
Safety story
I verified that release toggles are being parsed correctly for the
start_configurationAPI call and stored inPersonalIdSessionDatacorrectly.I also verified that the release toggles are stored correctly in the Connect DB after successful account recovery.
Automated test coverage
I added some basic stuff for unit testing the release toggles with the session data in
StartConfigurationResponseParserTest. I did not go too crazy with the unit tests considering that we already have all the tests inConnectReleaseTogglesParserTest. Let me know if I should add more tests forStartConfigurationResponseParserTest.I verified that all the unit tests ran successfully with my changes.
QA Plan
No action needed from QA on this ticket. I'm sure this will all be tested thoroughly via other tickets.