update fixes

This commit is contained in:
2023-11-24 11:58:17 +05:30
parent 23fde37e3d
commit d8fd352a62
11 changed files with 187 additions and 64 deletions

View File

@ -510,7 +510,7 @@ class DestinationController extends GetxController {
lat: la,
lon: ln,
is_checkin: isCheckin,
created_at: DateTime.now().microsecondsSinceEpoch);
created_at: DateTime.now().millisecondsSinceEpoch);
var res = await db.insertGps(gps_data);
print("==gps res == ${res}");
}
@ -559,10 +559,10 @@ class DestinationController extends GetxController {
LengthUnit.Meter, LatLng(latFs, lonFs), LatLng(la, ln));
Destination des = festuretoDestination(fs);
print(
"--- position is ---- ${position.longitude}, --- ${position.longitude}----");
//print(
// "--- position is ---- ${position.longitude}, --- ${position.longitude}----");
print("--- distFs ---- $distFs, --- ${des.checkin_radious}----");
//print("--- distFs ---- $distFs, --- ${des.checkin_radious}----");
if (distFs <= des.checkin_radious! && skipGps == false) {
//print("--- 789 ---- $skip_gps----");
//near a location
@ -571,6 +571,7 @@ class DestinationController extends GetxController {
break;
}
}
pushGPStoServer();
//print("--- 123 ---- $skip_gps----");
} catch (e) {
//print("An error occurred: $e");
@ -581,6 +582,19 @@ class DestinationController extends GetxController {
}
}
Future<void> pushGPStoServer() async {
try {
await Future.delayed(const Duration(minutes: 5));
ExternalService().pushGPS();
} catch (e) {
//print("An error occurred: $e");
await pushGPStoServer();
} finally {
//print("--- End of pushGPStoServer function, calling recursively ---");
await pushGPStoServer();
}
}
void addToRogaining(double lat, double lon, int destinationId) async {
DatabaseHelper db = DatabaseHelper.instance;
List<Destination> d = await db.getDestinationById(destinationId);
@ -665,7 +679,7 @@ class DestinationController extends GetxController {
DateTime now = DateTime.now();
String formattedDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(now);
await addGPStoDB(destination.lat!, destination.lon!, isCheckin: 1);
await addGPStoDB(currentLat, currentLon, isCheckin: 1);
// print("------ checkin event $eventCode ------");
ExternalService()
@ -869,9 +883,6 @@ class DestinationController extends GetxController {
// ---------- database ------------------///
void addDestinations(Destination dest) {
// print(
// '------ destination controller in add destination ${dest.checkin_radious} ---- :::::');
DatabaseHelper db = DatabaseHelper.instance;
db.getDestinationByLatLon(dest.lat!, dest.lon!).then((value) {
if (value.isNotEmpty) {
@ -947,40 +958,16 @@ class DestinationController extends GetxController {
}
void populateDestinations() {
//print(
// "--------- destination controller populsting destinations ----------- ::::::");
DatabaseHelper db = DatabaseHelper.instance;
destinations.clear();
db.getDestinations().then((value) {
destinationCount.value = 0;
for (Destination d in value) {
// print(
// "------ destination controller populating destination-------- ${d.checkedin}-------- :::::");
//print("-----populated----- ${d.toMap()}");
destinations.add(d);
}
if (destinations.isEmpty) {
rogainingCounted.value = false;
}
// destinationCount.value = 0;
//print(
// "------ destination controller destinationcount-------- $destinationCount-------- :::::");
// MatrixService.getDestinations(value).then((mat){
// print(" matrix is ------- ${mat}");
// matrix = mat;
// try{
// getRoutePoints();
// destinationCount.value = destinations.length;
// }
// catch(_){
// skip_gps = false;
// return;
// }
// });
});
}