feat: HOME-007 — server-side event title/description search (q param)

This commit is contained in:
2026-04-04 17:33:56 +05:30
parent e9752c3d61
commit 7cd64883e2
2 changed files with 25 additions and 4 deletions

View File

@@ -43,10 +43,11 @@ class EventsService {
/// Get events filtered by pincode with pagination.
/// [page] starts at 1. [pageSize] defaults to 50.
/// Returns a list of events for the requested page.
Future<List<EventModel>> getEventsByPincode(String pincode, {int page = 1, int pageSize = 50, int perType = 5}) async {
// Use cache for 'all' pincode queries (first page only for initial load)
Future<List<EventModel>> getEventsByPincode(String pincode, {int page = 1, int pageSize = 50, int perType = 5, String q = ''}) async {
// Use cache for 'all' pincode queries (first page only, no active search)
if (pincode == 'all' &&
page == 1 &&
q.isEmpty &&
_cachedAllEvents != null &&
_eventsCacheTime != null &&
DateTime.now().difference(_eventsCacheTime!) < _eventsCacheTTL) {
@@ -56,6 +57,8 @@ class EventsService {
final Map<String, dynamic> body = {'pincode': pincode, 'page': page, 'page_size': pageSize};
// Diverse mode: fetch a few events per type so all categories are represented
if (perType > 0 && page == 1) body['per_type'] = perType;
// Server-side search filter
if (q.isNotEmpty) body['q'] = q;
final res = await _api.post(
ApiEndpoints.eventsByPincode,