Skip to content
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

Add duplicate ZEIR ID cleanup job #168

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ local.properties
opensrp-unicef-tunisia/fabric.properties
opensrp-unicef-tunisia/jacoco.exec
opensrp-unicef-tunisia/reports/
opensrp-unicef-tunisia/debug/
opensrp-unicef-tunisia/preview/
opensrp-unicef-tunisia/release/
out/
project.properties
target/
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ subprojects {
ext.androidToolsBuildGradle = '4.0.1'
ext.androidBuildToolsVersion = '29.0.3'
ext.androidMinSdkVersion = 19
ext.androidCompileSdkVersion = 30
ext.androidTargetSdkVersion = 30
ext.androidCompileSdkVersion = 31
ext.androidTargetSdkVersion = 31

ext.androidAnnotationsVersion = '3.0.1'
ext.androidAnnotationsAPIVersion = '3.0.1'
Expand Down
38 changes: 25 additions & 13 deletions opensrp-unicef-tunisia/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,30 @@ android {
applicationVariants.all { variant ->
if (variant.name == "debug") {
variant.outputs.each { output ->
output.versionCodeOverride = 9
output.versionNameOverride = "0.2.5-debug"
output.versionCodeOverride = 12
output.versionNameOverride = "0.2.8-debug"
}
} else if (variant.name == "preview") {
variant.outputs.each { output ->
output.versionCodeOverride = 9
output.versionNameOverride = "0.2.5-preview"
output.versionCodeOverride = 11
output.versionNameOverride = "0.2.7-preview"
}
} else if (variant.name == "release") {
variant.outputs.each { output ->
output.versionCodeOverride = 10
output.versionNameOverride = "1.0.0"
output.versionCodeOverride = 12
output.versionNameOverride = "1.0.2"
}
}

configurations.all {
exclude group: 'com.evernote', module: 'android-job'
}

// https://stackoverflow.com/a/27119543/152938
variant.outputs.all { output ->
outputFileName = new File(outputFileName.replace(".apk", "-${output.versionNameOverride}.apk"))
println "Name of the APK is using versionNameOverride $outputFileName"
}
}

dexOptions {
Expand Down Expand Up @@ -132,7 +142,7 @@ android {
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '11'
buildConfigField "int", "VACCINE_SYNC_TIME", '0'
buildConfigField "int", "DATABASE_VERSION", '15'
buildConfigField "int", "DATABASE_VERSION", '16'
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
buildConfigField "boolean", "TIME_CHECK", "true"
buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15'
Expand All @@ -158,7 +168,7 @@ android {
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '12'
buildConfigField "int", "VACCINE_SYNC_TIME", '0'
buildConfigField "int", "DATABASE_VERSION", '15'
buildConfigField "int", "DATABASE_VERSION", '16'
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
buildConfigField "boolean", "TIME_CHECK", "true"
buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15'
Expand Down Expand Up @@ -190,7 +200,7 @@ android {
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '13'
buildConfigField "int", "VACCINE_SYNC_TIME", '0'
buildConfigField "int", "DATABASE_VERSION", '15'
buildConfigField "int", "DATABASE_VERSION", '16'
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
buildConfigField "boolean", "TIME_CHECK", "true"
buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15'
Expand Down Expand Up @@ -269,7 +279,7 @@ dependencies {
implementation "androidx.cardview:cardview:1.0.0"

// implementation(project(':opensrp-child')) {
implementation('org.smartregister:opensrp-client-child:0.7.1-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-child:0.10.1-SNAPSHOT@aar') {
transitive = true
exclude group: 'id.zelory', module: 'compressor'
exclude group: 'org.smartregister', module: 'opensrp-client-growth-monitoring'
Expand All @@ -286,7 +296,7 @@ dependencies {
exclude group: 'com.github.lecho', module: 'hellocharts-library'
}

implementation('org.smartregister:opensrp-client-immunization:4.0.3-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-immunization:4.0.6-SNAPSHOT@aar') {
transitive = true
exclude group: 'org.smartregister', module: 'opensrp-client-core'
exclude group: 'com.android.support', module: 'design'
Expand All @@ -298,7 +308,7 @@ dependencies {
exclude group: 'com.ibm.fhir', module: 'fhir-path'
}

implementation('org.smartregister:opensrp-client-core:4.3.24-BETA-2-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-core:5.1.1-SNAPSHOT@aar') {
transitive = true
exclude group: 'id.zelory', module: 'compressor'
exclude group: 'com.android.support', module: 'appcompat-v7'
Expand Down Expand Up @@ -371,7 +381,9 @@ dependencies {
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
implementation 'io.reactivex.rxjava2:rxjava:2.2.19'
implementation 'com.evernote:android-job:1.2.6'
implementation('com.github.devv911:android-job:1.4.5') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Create an issue to remove this and either update the client-core version or use an official version from evernote-job

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn 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.

I think the issue should be to remove this dependency with an official one or use client-core v6

exclude group: 'com.google.android', module: 'android'
}
implementation 'com.github.lecho:hellocharts-android:1.5.8'
implementation 'id.zelory:compressor:2.1.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
Expand Down
20 changes: 20 additions & 0 deletions opensrp-unicef-tunisia/debug/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's exclude this from the PR and add it to gitignore

"version": 1,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "org.smartregister.uniceftunisia",
"variantName": "debug",
"elements": [
{
"type": "SINGLE",
"filters": [],
"properties": [],
"versionCode": 11,
"versionName": "0.2.7-debug",
"enabled": true,
"outputFile": "opensrp-unicef-tunisia-debug-0.2.7-debug.apk"
}
]
}
21 changes: 11 additions & 10 deletions opensrp-unicef-tunisia/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
android:name=".activity.LoginActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.Login"
android:exported="true"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down Expand Up @@ -110,19 +111,19 @@
android:resource="@xml/captured_images_path" />
</provider>

<service android:name="org.smartregister.immunization.service.intent.VaccineIntentService" />
<service android:name="org.smartregister.immunization.service.intent.VaccineIntentService" />
<service android:name="org.smartregister.growthmonitoring.service.intent.ZScoreRefreshIntentService" />
<service android:name="org.smartregister.growthmonitoring.service.intent.WeightIntentService" />
<service android:name="org.smartregister.growthmonitoring.service.intent.HeightIntentService" />
<service android:name="org.smartregister.growthmonitoring.service.intent.WeightForHeightIntentService" />
<service android:name="org.smartregister.growthmonitoring.service.intent.WeightIntentService"/>
<service android:name="org.smartregister.growthmonitoring.service.intent.HeightIntentService"/>
<service android:name="org.smartregister.growthmonitoring.service.intent.WeightForHeightIntentService"/>
<service android:name="org.smartregister.sync.intent.SyncAllLocationsIntentService"/>
<service android:name="org.smartregister.sync.intent.PullUniqueIdsIntentService" />
<service android:name="org.smartregister.sync.intent.ValidateIntentService" />
<service android:name="org.smartregister.sync.intent.ExtendedSyncIntentService" />
<service android:name="org.smartregister.sync.intent.SettingsSyncIntentService" />
<service android:name="org.smartregister.sync.intent.PullUniqueIdsIntentService"/>
<service android:name="org.smartregister.sync.intent.ValidateIntentService"/>
<service android:name="org.smartregister.sync.intent.ExtendedSyncIntentService"/>
<service android:name="org.smartregister.sync.intent.SettingsSyncIntentService"/>
<service android:name=".service.intent.AppSyncIntentService"/>
<service android:name=".service.intent.ArchiveChildrenAgedAboveFiveIntentService" />
<service android:name=".service.intent.AppVaccineScheduleUpdateIntentService" />
<service android:name=".service.intent.ArchiveChildrenAgedAboveFiveIntentService"/>
<service android:name=".service.intent.AppVaccineScheduleUpdateIntentService"/>

<uses-library
android:name="org.apache.http.legacy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,9 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
super.onActivityResult(requestCode, resultCode, data);
}

@Override
public void updateViews() {
// Do nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AppCompatDelegate;

import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.core.CrashlyticsCore;
import com.evernote.android.job.JobManager;
import com.google.firebase.crashlytics.FirebaseCrashlytics;

Expand Down Expand Up @@ -73,6 +75,7 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;

import io.fabric.sdk.android.Fabric;
import timber.log.Timber;

public class UnicefTunisiaApplication extends DrishtiApplication implements TimeChangedBroadcastReceiver.OnTimeChangedListener, Application.ActivityLifecycleCallbacks {
Expand Down Expand Up @@ -220,6 +223,9 @@ public void onCreate() {
context = Context.getInstance();
registerActivityLifecycleCallbacks(this);

Fabric.with(this, new Crashlytics.Builder().core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()).build());
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(!BuildConfig.DEBUG);

context.updateApplicationContext(getApplicationContext());
context.updateCommonFtsObject(createCommonFtsObject(context.applicationContext()));

Expand Down Expand Up @@ -247,8 +253,6 @@ public void onCreate() {
ReportingLibrary.init(context, getRepository(), null, BuildConfig.VERSION_CODE, BuildConfig.DATABASE_VERSION);
ReportingLibrary.getInstance().addMultiResultProcessor(new ReportIndicatorsProcessor());

FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(!BuildConfig.DEBUG);

initRepositories();

SyncStatusBroadcastReceiver.init(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.smartregister.growthmonitoring.job.WeightIntentServiceJob;
import org.smartregister.growthmonitoring.job.ZScoreRefreshIntentServiceJob;
import org.smartregister.immunization.job.VaccineServiceJob;
import org.smartregister.job.DuplicateZeirIdsCleanerWorker;
import org.smartregister.job.ImageUploadServiceJob;
import org.smartregister.job.PullUniqueIdsServiceJob;
import org.smartregister.job.SyncAllLocationsServiceJob;
Expand Down Expand Up @@ -69,5 +70,12 @@ protected void scheduleJobsImmediately() {
ZScoreRefreshIntentServiceJob.scheduleJobImmediately(ZScoreRefreshIntentServiceJob.TAG);
ImageUploadServiceJob.scheduleJobImmediately(ImageUploadServiceJob.TAG);
ArchiveClientsJob.scheduleJobImmediately(ArchiveClientsJob.TAG);
/*
This job will not be duplicated but is added here since scheduleJobsPeriodically is only called
after a remote login and therefore might be run too late. scheduleJobsImmediately is called
after both remote login and local login
*/
String[] eventTypes = new String[]{"Father Registration"};
DuplicateZeirIdsCleanerWorker.schedulePeriodically(getApplicationContext(), 15, eventTypes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
public class AppChildRegisterModel extends BaseChildRegisterModel {

@Override
public List<ChildEventClient> processRegistration(@NonNull String jsonString, FormTag formTag) {
List<ChildEventClient> childEventClients = super.processRegistration(jsonString, formTag);
public List<ChildEventClient> processRegistration(@NonNull String jsonString, FormTag formTag, boolean isEditMode) {
List<ChildEventClient> childEventClients = super.processRegistration(jsonString, formTag, isEditMode);
//Add location name as part of child attributes to avoid fetching name from events
for (ChildEventClient childEventClient : childEventClients) {
Client client = childEventClient.getClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import org.smartregister.AllConstants;
import org.smartregister.child.util.ChildDbMigrations;
import org.smartregister.child.util.Utils;
import org.smartregister.child.util.VaccineOverdueCountRepositoryHelper;
import org.smartregister.configurableviews.repository.ConfigurableViewsRepository;
import org.smartregister.domain.db.Column;
import org.smartregister.growthmonitoring.repository.HeightRepository;
import org.smartregister.growthmonitoring.repository.HeightZScoreRepository;
import org.smartregister.growthmonitoring.repository.WeightForHeightRepository;
import org.smartregister.growthmonitoring.repository.WeightRepository;
import org.smartregister.growthmonitoring.repository.WeightZScoreRepository;
import org.smartregister.immunization.repository.VaccineOverdueCountRepository;
import org.smartregister.immunization.repository.VaccineRepository;
import org.smartregister.reporting.ReportingLibrary;
import org.smartregister.reporting.repository.DailyIndicatorCountRepository;
Expand Down Expand Up @@ -134,6 +136,8 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
upgradeToVersion14(db);
case 15:
upgradeToVersion15(db);
case 16:
upgradeToVersion16(db);
default:
break;
}
Expand Down Expand Up @@ -361,4 +365,43 @@ private void upgradeToVersion15(SQLiteDatabase db) {
Timber.e(e, "upgradeToVersion15");
}
}

private void upgradeToVersion16(SQLiteDatabase db) {
try {
// Add vaccine overdue table and migration vaccines
db.execSQL(VaccineOverdueCountRepository.CREATE_TABLE_SQL);
db.execSQL(VaccineOverdueCountRepositoryHelper.MIGRATE_VACCINES_QUERY);

addOutreachColumn(db);
addDateRemovedColumnChildDetailsTable(db);
} catch (Exception e) {
Timber.e(e);
}
}

private void addOutreachColumn(SQLiteDatabase db) {
try {
String UPDATE_VACCINES_TABLE_ADD_OUTREACH = "ALTER TABLE " + VaccineRepository.VACCINE_TABLE_NAME + " ADD COLUMN outreach INTEGER;";
db.execSQL(UPDATE_VACCINES_TABLE_ADD_OUTREACH);
db.execSQL(HeightRepository.UPDATE_TABLE_ADD_CHILD_LOCATION_ID_COL);
db.execSQL(HeightRepository.UPDATE_TABLE_ADD_TEAM_COL);
db.execSQL(HeightRepository.UPDATE_TABLE_ADD_TEAM_ID_COL);
db.execSQL(HeightRepository.UPDATE_TABLE_ADD_EVENT_ID_COL);
db.execSQL(HeightRepository.UPDATE_TABLE_ADD_FORMSUBMISSION_ID_COL);
db.execSQL(HeightRepository.ALTER_ADD_Z_SCORE_COLUMN);
db.execSQL(HeightRepository.UPDATE_TABLE_ADD_OUT_OF_AREA_COL);
db.execSQL(HeightRepository.ALTER_ADD_CREATED_AT_COLUMN);
} catch (Exception e) {
Timber.e(e);
}
}

private void addDateRemovedColumnChildDetailsTable(SQLiteDatabase database) {
try {
String UPDATE_CHILD_DETAILS_TABLE_ADD_DATE_REMOVED = "ALTER TABLE ec_child_details ADD COLUMN date_removed VARCHAR;";
database.execSQL(UPDATE_CHILD_DETAILS_TABLE_ADD_DATE_REMOVED);
} catch (Exception e) {
Timber.e(e);
}
}
}