Trigger app sync after a task change#3791
Conversation
|
@coderabbitai full review please |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
gh pr view 3791 --repo dimagi/commcare-android --json title,body,files,additions,deletions,changedFiles,baseRefName,headRefName
echo "---DIFF---"
gh pr diff 3791 --repo dimagi/commcare-androidLength of output: 11057 🏁 Script executed: #!/bin/bash
set -euo pipefail
sed -n '1,140p' app/src/org/commcare/connect/database/ConnectTaskUtils.ktLength of output: 5345 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "---ConnectJobHelper.getJobForSeatedApp---"
rg -n "getJobForSeatedApp" -A 20 app/src/org/commcare/connect/ConnectJobHelper.kt 2>/dev/null || rg -n "getJobForSeatedApp" -A 20 --type=java --type=kotlin -g '*.kt' -g '*.java' .
echo "---SyncDetailCalculations.getLastSyncTime---"
rg -n "getLastSyncTime" -A 15 app/src/org/commcare/utils/SyncDetailCalculations.kt 2>/dev/null || rg -n "fun getLastSyncTime" -A 15 -g '*.kt' .
echo "---ConnectJobPreferences taskModifiedTime---"
rg -n "TaskModifiedTime|TIMESTAMP_NOT_SET" -A 5 app/src/org/commcare/preferences/ConnectJobPreferences.ktLength of output: 6414 🏁 Script executed: #!/bin/bash
set -euo pipefail
fd -i "SyncDetailCalculations"
echo "---"
rg -n "getLastSyncTime|class SyncDetailCalculations|object SyncDetailCalculations" -A 8 $(fd -i "SyncDetailCalculations.kt")Length of output: 564 🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n "getLastSyncTime|class SyncDetailCalculations" -A 10 app/src/org/commcare/utils/SyncDetailCalculations.javaLength of output: 3103 🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n "checkForPendingAppHealthActions" -B5 -A 40 app/src/org/commcare/activities/HomeScreenBaseActivity.java | head -100Length of output: 4902 This looks well-integrated: A couple of things worth double-checking with the author, plus one minor nit:
Overall the change is small, well-scoped, and consistent with existing patterns in ✅ Action performedReview finished.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3791 +/- ##
============================================
+ Coverage 26.14% 26.57% +0.43%
- Complexity 4462 4581 +119
============================================
Files 954 971 +17
Lines 57383 58018 +635
Branches 6830 6909 +79
============================================
+ Hits 15002 15421 +419
- Misses 40545 40715 +170
- Partials 1836 1882 +46 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
📝 WalkthroughWalkthroughThis change adds a new utility function Estimated code review effort: 2 (Simple) | ~12 minutes Sequence Diagram(s)sequenceDiagram
participant HomeScreenBaseActivity
participant ConnectTaskUtils
participant ConnectJobHelper
participant SyncDetailCalculations
HomeScreenBaseActivity->>ConnectTaskUtils: isLastTaskUpdateLaterThanLastSync(context)
ConnectTaskUtils->>ConnectJobHelper: getJobForSeatedApp()
ConnectJobHelper-->>ConnectTaskUtils: seated job
alt job seated and STATUS_DELIVERING and task modified time set
ConnectTaskUtils->>SyncDetailCalculations: getLastSyncTime()
SyncDetailCalculations-->>ConnectTaskUtils: last sync time
ConnectTaskUtils-->>HomeScreenBaseActivity: comparison result
else conditions not met
ConnectTaskUtils-->>HomeScreenBaseActivity: false
end
HomeScreenBaseActivity->>HomeScreenBaseActivity: triggerSync(true) if true
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
conroy-ricketts
left a comment
There was a problem hiding this comment.
Can we update the safety story as well
| import static org.commcare.activities.DispatchActivity.EXIT_AFTER_FORM_SUBMISSION; | ||
| import static org.commcare.activities.DispatchActivity.EXIT_AFTER_FORM_SUBMISSION_DEFAULT; | ||
| import static org.commcare.activities.DispatchActivity.SESSION_ENDPOINT_ARGUMENTS_BUNDLE; | ||
| import static org.commcare.activities.DispatchActivity.SESSION_ENDPOINT_ARGUMENTS_LIST; | ||
| import static org.commcare.activities.DispatchActivity.SESSION_ENDPOINT_ID; | ||
| import static org.commcare.activities.DriftHelper.getCurrentDrift; | ||
| import static org.commcare.activities.DriftHelper.getDriftDialog; | ||
| import static org.commcare.activities.DriftHelper.shouldShowDriftWarning; | ||
| import static org.commcare.activities.DriftHelper.updateLastDriftWarningTime; | ||
| import static org.commcare.activities.EntitySelectActivity.EXTRA_ENTITY_KEY; | ||
| import static org.commcare.appupdate.AppUpdateController.IN_APP_UPDATE_REQUEST_CODE; | ||
| import static org.commcare.connect.ConnectConstants.PERSONALID_MANAGED_LOGIN; | ||
| import static org.commcare.connect.database.ConnectTaskUtils.isLastTaskUpdateLaterThanLastSync; | ||
|
|
There was a problem hiding this comment.
The static imports actually got relocated to the top of the file. However, .github/linters/checkstyle.xml prefers them at the bottom. Did they move automatically?
There was a problem hiding this comment.
thanks for flagging, reverted this here - 15f531b , It was triggered by rearrange imports shortcut on mac (ctrl + option + O) which doesn't seem to be taking into account the code style file
The base branch was changed.
Product Description
https://dimagi.atlassian.net/browse/CCCT-2541
Every time user enters an app, we trigger an automated sync if a task has changes since the last time an app sync was performed.
task_sync.mp4
Technical Summary
Spec
Safety Assurance
Safety story
Tested locally by changing tasks and verified that sync occurs only when a task has changed
Automated test coverage
new behaviour is covered with tests, any regressions should be flagged by existing CC side integration tests.
Labels and Review