-
Notifications
You must be signed in to change notification settings - Fork 3
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
Process skipped clients #506
base: master
Are you sure you want to change the base?
Conversation
import org.smartregister.giz.service.ReProcessSyncIntentService; | ||
import org.smartregister.job.BaseJob; | ||
|
||
public class GizReProcessJob extends BaseJob { |
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.
Rename this to GIZClientReprocessJob
for now
if (fetchStatusSerializable instanceof FetchStatus) { | ||
FetchStatus fetchStatus = (FetchStatus) fetchStatusSerializable; | ||
if (fetchStatus.equals(FetchStatus.fetched)) { | ||
GizReProcessJob.scheduleJobImmediately(GizReProcessJob.TAG); |
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.
I believe we want to call the job once sync is complete eg sync is done fetching all the latest records and not successfully fetched one batch. I'm not sure if this is what is currently implemented
|
||
|
||
try { | ||
if(formSubmissionIDs.size()>0) |
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.
Reformat the code to fix spacing in the if statement
e.printStackTrace(); | ||
} | ||
} | ||
|
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.
Use Timber to print exceptions. It sends exceptions to Crashlytics
try { | ||
if(formSubmissionIDs.size()>0) | ||
GizUtils.initiateEventProcessing(formSubmissionIDs); | ||
} catch (Exception e) { |
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.
I don't think we should be generally catching Exception here
{ | ||
String missingClientRegister = "SELECT DISTINCT baseEntityId, formSubmissionId AS formSubmissionId FROM event WHERE baseEntityId IN (SELECT baseEntityId FROM client WHERE baseEntityId NOT IN (SELECT DISTINCT base_entity_id FROM client_register_type)) AND eventType LIKE '%Registration%'"; | ||
String missingECClient = "SELECT DISTINCT baseEntityId, formSubmissionId AS formSubmissionId FROM event WHERE baseEntityId IN (SELECT baseEntityId FROM client WHERE baseEntityId NOT IN (SELECT DISTINCT base_entity_id FROM ec_client)) AND eventType LIKE '%Registration%'"; | ||
List<String> formSubmissionIDs = new ArrayList<>(); |
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 list allows duplicates which might not be handled
Fix codacy and build checks. Kindly make sure you fix this before requesting for a review |
|
||
import static org.smartregister.receiver.SyncStatusBroadcastReceiver.EXTRA_FETCH_STATUS; | ||
|
||
public class SyncStatusReciever extends BroadcastReceiver { |
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.
Rename this to GizReprocessSyncStatusReceiver
since this is only being used by the GizClientReprocessJob
SQLiteDatabase database = getReadableDatabase(); | ||
Cursor cursor = database.rawQuery(query, null); | ||
int columnIndex = cursor.getColumnIndex("formSubmissionId"); | ||
if(cursor.getCount() > 0) { |
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.
Reformat the code file to fix the spacing
@@ -21,4 +25,37 @@ public boolean hasEvent(@NonNull String baseEntityId, @NonNull String eventType) | |||
} | |||
return hasEvent; | |||
} | |||
|
|||
public void ReprocessClients() |
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.
😄 camelCase
please and let's rename this to processSkippedClients
or something a bit more descriptive enough that only unprocessed clients are being processed here
|
||
public class ReProcessSyncIntentService extends IntentService { | ||
|
||
public static final String TAG = "ReValidateSyncIntentService"; |
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.
Let's have the tag similar to the name of the service
|
||
public class GIZClientReprocessJob extends BaseJob { | ||
|
||
public static final String TAG = "GizReValidationJob"; |
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.
Change this tag also to match the Job
…e action added a check for existing formsubmission id while population the list corrected the job tag
if(isComplete) | ||
{ | ||
GIZClientReprocessJob.scheduleJobImmediately(GIZClientReprocessJob.TAG); | ||
Timber.d("fetch completed"); |
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 log might be misleading
opensrp-giz-malawi/build.gradle
Outdated
@@ -404,6 +404,8 @@ dependencies { | |||
|
|||
implementation "androidx.multidex:multidex:2.0.1" | |||
testImplementation "androidx.work:work-testing:2.7.1" | |||
androidTestImplementation 'androidx.test:runner:1.3.0' |
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.
These two are also applied for instrumentation tests that are not changed in this PR. Confirm that we need these and probably change this to testImplementation
if (cursor.getCount() > 0) { | ||
cursor.moveToFirst(); | ||
do { | ||
if (!ids.contains(cursor.getString(columnIndex))) |
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.
Time complexity for contains is n. I still believe that a HashSet is better here
@@ -21,4 +27,33 @@ public boolean hasEvent(@NonNull String baseEntityId, @NonNull String eventType) | |||
} | |||
return hasEvent; | |||
} | |||
|
|||
public void processSkippedClients() { | |||
String missingClientRegister = "SELECT DISTINCT baseEntityId, formSubmissionId AS formSubmissionId FROM event WHERE baseEntityId IN (SELECT baseEntityId FROM client WHERE baseEntityId NOT IN (SELECT DISTINCT base_entity_id FROM client_register_type)) AND eventType LIKE '%Registration%'"; |
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.
I am not sure we need to alias formSubmissionId here
|
||
public void processSkippedClients() { | ||
String missingClientRegister = "SELECT DISTINCT baseEntityId, formSubmissionId AS formSubmissionId FROM event WHERE baseEntityId IN (SELECT baseEntityId FROM client WHERE baseEntityId NOT IN (SELECT DISTINCT base_entity_id FROM client_register_type)) AND eventType LIKE '%Registration%'"; | ||
String missingECClient = "SELECT DISTINCT baseEntityId, formSubmissionId AS formSubmissionId FROM event WHERE baseEntityId IN (SELECT baseEntityId FROM client WHERE baseEntityId NOT IN (SELECT DISTINCT base_entity_id FROM ec_client)) AND eventType LIKE '%Registration%'"; |
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.
check previous comment on formSubmissionId
<service android:name="org.smartregister.sync.intent.SettingsSyncIntentService" /> | ||
<service android:name="org.smartregister.sync.intent.SyncIntentService" /> | ||
<service android:name=".service.ReProcessSyncIntentService"/> | ||
<service android:name="org.smartregister.immunization.service.intent.VaccineIntentService" android:exported="true" /> |
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.
Why are these services set as exported
and why is this explicitly declared?
} | ||
} | ||
|
||
Timber.d("broadcast Recieved"); |
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.
I think the log is too vague and it would be easier to understand if it was a bit more specific on the broadcast that was received
… clients - Update versionCode and versionName to 47 and 0.4.7
- Update immunization library to fix duplicate vaccines and services - Fix client-core version
- Add config to close ec_client records when an OPD Close event is encountered - Filter out closed records from the OPD register
- Update child register query to use ec_client.is_removed flag
- These events had not been previously processed due to a bug
issue ref : https://github.com/opensrp/support/issues/267