parseLocationData function
Implementation
Future<List<UserActionModel>> parseLocationData(List<String> logs) async {
List<UserActionModel> locationDataList = [];
for (var log in logs) {
final pattern = RegExp(
r'Latitude:\s*(-?\d+\.\d+),\s*Longitude:\s*(-?\d+\.\d+),\s*Accuracy:\s*(\d+\.\d+),\s*isSync:\s*(\w+),\s*timestamp:\s*(\d+)');
final match = pattern.firstMatch(log);
if (match != null) {
final latitude = double.parse(match.group(1)!);
final longitude = double.parse(match.group(2)!);
final accuracy = double.parse(match.group(3)!);
final isSync = match.group(4)!.toLowerCase() == 'true';
final timestamp = int.parse(match.group(5)!);
locationDataList.add(UserActionModel(
latitude: latitude,
longitude: longitude,
locationAccuracy: accuracy,
tenantId: LocationTrackerSingleton().tenantId,
clientReferenceId: IdGen.instance.identifier,
isSync: isSync,
timestamp: timestamp,
boundaryCode: LocationTrackerSingleton().boundaryName,
action: 'LOCATION_CAPTURE',
projectId: LocationTrackerSingleton().projectId,
rowVersion: 1,
auditDetails: AuditDetails(
createdBy: LocationTrackerSingleton().loggedInUserUuid,
createdTime: DateTime.now().millisecondsSinceEpoch,
lastModifiedBy: LocationTrackerSingleton().loggedInUserUuid,
lastModifiedTime: DateTime.now().millisecondsSinceEpoch,
),
clientAuditDetails: ClientAuditDetails(
createdBy: LocationTrackerSingleton().loggedInUserUuid,
createdTime: DateTime.now().millisecondsSinceEpoch,
lastModifiedBy: LocationTrackerSingleton().loggedInUserUuid,
lastModifiedTime: DateTime.now().millisecondsSinceEpoch,
),
));
}
}
return locationDataList;
}