From 452c2ee997485a50c08e01ceaeacbbb25442fdb0 Mon Sep 17 00:00:00 2001 From: Naveen Renati <154230258+naveenr-egov@users.noreply.github.com> Date: Thu, 5 Dec 2024 21:42:39 +0530 Subject: [PATCH] V1.5 sync count patch (#620) * updated hardcoded sync count, retry count and error api path * Published digit_data_model version update --- packages/digit_data_model/CHANGELOG.md | 5 + .../lib/data/data_repository.dart | 2 +- .../lib/data/repositories/oplog/oplog.dart | 11 +- .../record_reason_checklist.dart | 110 +++++++++--------- .../lib/pages/survey_form_view.dart | 29 +++-- 5 files changed, 84 insertions(+), 73 deletions(-) diff --git a/packages/digit_data_model/CHANGELOG.md b/packages/digit_data_model/CHANGELOG.md index 094746386..99fb77765 100644 --- a/packages/digit_data_model/CHANGELOG.md +++ b/packages/digit_data_model/CHANGELOG.md @@ -2,6 +2,11 @@ * Merged pgr and survey_form package changes +## 1.0.4+1 + +* Bug Fix: + * Updated syncRetryCount,syncRetryInterval and errorPath to dynamic + ## 1.0.4 * Added user_action entity for digit_location_tracker package diff --git a/packages/digit_data_model/lib/data/data_repository.dart b/packages/digit_data_model/lib/data/data_repository.dart index 6561840fd..869831b1f 100644 --- a/packages/digit_data_model/lib/data/data_repository.dart +++ b/packages/digit_data_model/lib/data/data_repository.dart @@ -297,7 +297,7 @@ abstract class RemoteRepository { .syncedDownEqualTo(false) .nonRecoverableErrorEqualTo(false) .syncDownRetryCountGreaterThan( - 5 - 1, + DigitDataModelSingleton().syncDownRetryCount - 1, ) .createdByEqualTo(createdBy) .findAllSync(); @@ -112,7 +112,8 @@ abstract class OpLogManager { var oplogs = isar.opLogs .filter() .syncedUpEqualTo(true) - .syncDownRetryCountLessThan(5) + .syncDownRetryCountLessThan( + DigitDataModelSingleton().syncDownRetryCount) .syncedDownEqualTo(false) .entityTypeEqualTo(type) .findAllSync(); @@ -299,7 +300,8 @@ abstract class OpLogManager { OpLogEntry updatedEntry = entry.copyWith( syncDownRetryCount: syncDownRetryCount + 1, ); - if (updatedEntry.syncDownRetryCount >= 5) { + if (updatedEntry.syncDownRetryCount >= + DigitDataModelSingleton().syncDownRetryCount) { markAsNonRecoverable = true; updatedEntry = updatedEntry.copyWith(nonRecoverableError: true); } @@ -315,7 +317,8 @@ abstract class OpLogManager { await Future.delayed(const Duration(seconds: 1)); } else { await Future.delayed(Duration( - seconds: 5 * oplogs.first.syncDownRetryCount, + seconds: DigitDataModelSingleton().retryTimeInterval * + oplogs.first.syncDownRetryCount, )); } diff --git a/packages/referral_reconciliation/lib/pages/create_referral/record_reason_checklist.dart b/packages/referral_reconciliation/lib/pages/create_referral/record_reason_checklist.dart index 78393d784..06caed99b 100644 --- a/packages/referral_reconciliation/lib/pages/create_referral/record_reason_checklist.dart +++ b/packages/referral_reconciliation/lib/pages/create_referral/record_reason_checklist.dart @@ -196,60 +196,64 @@ class _ReferralReasonChecklistPageState context.read().add( ServiceCreateEvent( serviceModel: ServiceModel( - createdAt: DigitDateUtils - .getDateFromTimestamp( - DateTime.now() - .toLocal() - .millisecondsSinceEpoch, - dateFormat: - defaultDateTimeFormat, - ), - tenantId: value - .selectedServiceDefinition! - .tenantId, - clientId: widget - .referralClientRefId - .toString(), - serviceDefId: value - .selectedServiceDefinition - ?.id, - attributes: attributes, - rowVersion: 1, - accountId: - ReferralReconSingleton() - .projectId, - auditDetails: AuditDetails( - createdBy: - ReferralReconSingleton() - .userUUid, - createdTime: context - .millisecondsSinceEpoch(), - lastModifiedBy: - ReferralReconSingleton() - .userUUid, - lastModifiedTime: context - .millisecondsSinceEpoch(), - ), - clientAuditDetails: - ClientAuditDetails( - createdBy: - ReferralReconSingleton() - .userUUid, - createdTime: context - .millisecondsSinceEpoch(), - lastModifiedBy: - ReferralReconSingleton() - .userUUid, - lastModifiedTime: context - .millisecondsSinceEpoch(), - ), - additionalDetails: { - "boundaryCode": + createdAt: DigitDateUtils + .getDateFromTimestamp( + DateTime.now() + .toLocal() + .millisecondsSinceEpoch, + dateFormat: + defaultDateTimeFormat, + ), + tenantId: value + .selectedServiceDefinition! + .tenantId, + clientId: widget + .referralClientRefId + .toString(), + serviceDefId: value + .selectedServiceDefinition + ?.id, + attributes: attributes, + rowVersion: 1, + accountId: ReferralReconSingleton() - .boundary - ?.code - }, - ), + .projectId, + auditDetails: + AuditDetails( + createdBy: + ReferralReconSingleton() + .userUUid, + createdTime: context + .millisecondsSinceEpoch(), + lastModifiedBy: + ReferralReconSingleton() + .userUUid, + lastModifiedTime: context + .millisecondsSinceEpoch(), + ), + clientAuditDetails: + ClientAuditDetails( + createdBy: + ReferralReconSingleton() + .userUUid, + createdTime: context + .millisecondsSinceEpoch(), + lastModifiedBy: + ReferralReconSingleton() + .userUUid, + lastModifiedTime: context + .millisecondsSinceEpoch(), + ), + additionalFields: + ServiceAdditionalFields( + version: 1, + fields: [ + AdditionalField( + 'boundaryCode', + SurveyFormSingleton() + .boundary + ?.code) + ])), ), ); diff --git a/packages/survey_form/lib/pages/survey_form_view.dart b/packages/survey_form/lib/pages/survey_form_view.dart index ce0bfc65f..f70231157 100644 --- a/packages/survey_form/lib/pages/survey_form_view.dart +++ b/packages/survey_form/lib/pages/survey_form_view.dart @@ -259,6 +259,11 @@ class SurveyFormViewPageState extends LocalizedState { 'longitude', longitude, ), + AdditionalField( + 'boundaryCode', + SurveyFormSingleton() + .boundary + ?.code) ], ), )); @@ -726,8 +731,8 @@ class SurveyFormViewPageState extends LocalizedState { builder: (field) => RadioList( radioDigitButtons: item.values != null ? item.values! - .where((e) => - e != i18.surveyForm.notSelectedKey) + .where( + (e) => e != i18.surveyForm.notSelectedKey) .toList() .map((item) => RadioButtonModel( code: item, @@ -750,8 +755,8 @@ class SurveyFormViewPageState extends LocalizedState { setState(() { // Clear child controllers and update visibility for (final matchingChildItem in childItems) { - final childIndex = initialAttributes - ?.indexOf(matchingChildItem); + final childIndex = + initialAttributes?.indexOf(matchingChildItem); if (childIndex != null) { // controller[childIndex].clear(); visibleSurveyFormIndexes @@ -768,9 +773,7 @@ class SurveyFormViewPageState extends LocalizedState { ).value; if (excludedIndexes.isNotEmpty) { - for (int i = 0; - i < excludedIndexes.length; - i++) { + for (int i = 0; i < excludedIndexes.length; i++) { // Clear excluded child controllers if (item.dataType != 'SingleValueList') { // controller[excludedIndexes[i]].value = @@ -793,8 +796,7 @@ class SurveyFormViewPageState extends LocalizedState { ), BlocBuilder( builder: (context, state) { - return (controller[index].text == - item.values?[1].trim() && + return (controller[index].text == item.values?[1].trim() && !(isHealthFacilityWorker && widget.referralClientRefId != null)) ? Padding( @@ -808,10 +810,8 @@ class SurveyFormViewPageState extends LocalizedState { AutovalidateMode.onUserInteraction, validator: (value1) { if (item.required == true && - (additionalController[index].text == - null || - additionalController[index].text == - '')) { + (additionalController[index].text == null || + additionalController[index].text == '')) { return localizations.translate( i18.common.coreCommonReasonRequired, ); @@ -828,8 +828,7 @@ class SurveyFormViewPageState extends LocalizedState { child: DigitTextFormInput( onChange: (value) { field.didChange(value); - additionalController[index].text = - value; + additionalController[index].text = value; }, errorMessage: field.errorText, maxLength: 1000,