Update default location to Thrissur and remove Whitefield, Bengaluru
This commit is contained in:
@@ -109,30 +109,24 @@ class EventsService {
|
||||
}
|
||||
|
||||
/// Get events by GPS coordinates using haversine distance filtering.
|
||||
/// Automatically expands radius (10 → 25 → 50 → 100 km) until ≥ 6 events found.
|
||||
Future<List<EventModel>> getEventsByLocation(double lat, double lng, {double initialRadiusKm = 10}) async {
|
||||
const radii = [10.0, 25.0, 50.0, 100.0];
|
||||
for (final radius in radii) {
|
||||
if (radius < initialRadiusKm) continue;
|
||||
final body = {
|
||||
'latitude': lat,
|
||||
'longitude': lng,
|
||||
'radius_km': radius,
|
||||
'page': 1,
|
||||
'page_size': 50,
|
||||
'per_type': 5,
|
||||
};
|
||||
final res = await _api.post(ApiEndpoints.eventsByPincode, body: body, requiresAuth: false);
|
||||
final list = <EventModel>[];
|
||||
final events = res['events'] ?? res['data'] ?? [];
|
||||
if (events is List) {
|
||||
for (final e in events) {
|
||||
if (e is Map<String, dynamic>) list.add(EventModel.fromJson(Map<String, dynamic>.from(e)));
|
||||
}
|
||||
Future<List<EventModel>> getEventsByLocation(double lat, double lng, {double radiusKm = 10.0}) async {
|
||||
final body = {
|
||||
'latitude': lat,
|
||||
'longitude': lng,
|
||||
'radius_km': radiusKm,
|
||||
'page': 1,
|
||||
'page_size': 50,
|
||||
'per_type': 5,
|
||||
};
|
||||
final res = await _api.post(ApiEndpoints.eventsByPincode, body: body, requiresAuth: false);
|
||||
final list = <EventModel>[];
|
||||
final events = res['events'] ?? res['data'] ?? [];
|
||||
if (events is List) {
|
||||
for (final e in events) {
|
||||
if (e is Map<String, dynamic>) list.add(EventModel.fromJson(Map<String, dynamic>.from(e)));
|
||||
}
|
||||
if (list.length >= 6 || radius >= 100) return list;
|
||||
}
|
||||
return [];
|
||||
return list;
|
||||
}
|
||||
|
||||
/// Events by month and year for calendar (POST to /events/events-by-month-year/)
|
||||
|
||||
Reference in New Issue
Block a user