Skip to content

Commit

Permalink
V1.5 sync count patch (#620)
Browse files Browse the repository at this point in the history
* updated hardcoded sync count, retry count and error api path

* Published digit_data_model version update
  • Loading branch information
naveenr-egov committed Dec 12, 2024
1 parent 8f256e0 commit 452c2ee
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 73 deletions.
5 changes: 5 additions & 0 deletions packages/digit_data_model/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/digit_data_model/lib/data/data_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ abstract class RemoteRepository<D extends EntityModel,
}

return await dio.post(
'error-handler/handle-error', // [TODO: Update this URL]
DigitDataModelSingleton().errorDumpApiPath,
options: Options(headers: {
"content-type": 'application/json',
}),
Expand Down
11 changes: 7 additions & 4 deletions packages/digit_data_model/lib/data/repositories/oplog/oplog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ abstract class OpLogManager<T extends EntityModel> {
.syncedDownEqualTo(false)
.nonRecoverableErrorEqualTo(false)
.syncDownRetryCountGreaterThan(
5 - 1,
DigitDataModelSingleton().syncDownRetryCount - 1,
)
.createdByEqualTo(createdBy)
.findAllSync();
Expand Down Expand Up @@ -112,7 +112,8 @@ abstract class OpLogManager<T extends EntityModel> {
var oplogs = isar.opLogs
.filter()
.syncedUpEqualTo(true)
.syncDownRetryCountLessThan(5)
.syncDownRetryCountLessThan(
DigitDataModelSingleton().syncDownRetryCount)
.syncedDownEqualTo(false)
.entityTypeEqualTo(type)
.findAllSync();
Expand Down Expand Up @@ -299,7 +300,8 @@ abstract class OpLogManager<T extends EntityModel> {
OpLogEntry updatedEntry = entry.copyWith(
syncDownRetryCount: syncDownRetryCount + 1,
);
if (updatedEntry.syncDownRetryCount >= 5) {
if (updatedEntry.syncDownRetryCount >=
DigitDataModelSingleton().syncDownRetryCount) {
markAsNonRecoverable = true;
updatedEntry = updatedEntry.copyWith(nonRecoverableError: true);
}
Expand All @@ -315,7 +317,8 @@ abstract class OpLogManager<T extends EntityModel> {
await Future.delayed(const Duration(seconds: 1));
} else {
await Future.delayed(Duration(
seconds: 5 * oplogs.first.syncDownRetryCount,
seconds: DigitDataModelSingleton().retryTimeInterval *
oplogs.first.syncDownRetryCount,
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,60 +196,64 @@ class _ReferralReasonChecklistPageState
context.read<ServiceBloc>().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)
])),
),
);

Expand Down
29 changes: 14 additions & 15 deletions packages/survey_form/lib/pages/survey_form_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ class SurveyFormViewPageState extends LocalizedState<SurveyFormViewPage> {
'longitude',
longitude,
),
AdditionalField(
'boundaryCode',
SurveyFormSingleton()
.boundary
?.code)
],
),
));
Expand Down Expand Up @@ -726,8 +731,8 @@ class SurveyFormViewPageState extends LocalizedState<SurveyFormViewPage> {
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,
Expand All @@ -750,8 +755,8 @@ class SurveyFormViewPageState extends LocalizedState<SurveyFormViewPage> {
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
Expand All @@ -768,9 +773,7 @@ class SurveyFormViewPageState extends LocalizedState<SurveyFormViewPage> {
).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 =
Expand All @@ -793,8 +796,7 @@ class SurveyFormViewPageState extends LocalizedState<SurveyFormViewPage> {
),
BlocBuilder<ServiceBloc, ServiceState>(
builder: (context, state) {
return (controller[index].text ==
item.values?[1].trim() &&
return (controller[index].text == item.values?[1].trim() &&
!(isHealthFacilityWorker &&
widget.referralClientRefId != null))
? Padding(
Expand All @@ -808,10 +810,8 @@ class SurveyFormViewPageState extends LocalizedState<SurveyFormViewPage> {
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,
);
Expand All @@ -828,8 +828,7 @@ class SurveyFormViewPageState extends LocalizedState<SurveyFormViewPage> {
child: DigitTextFormInput(
onChange: (value) {
field.didChange(value);
additionalController[index].text =
value;
additionalController[index].text = value;
},
errorMessage: field.errorText,
maxLength: 1000,
Expand Down

0 comments on commit 452c2ee

Please sign in to comment.