From 4424932fed7110505ab23535529a80a332ccbf73 Mon Sep 17 00:00:00 2001 From: Ashish Bailkeri Date: Sat, 25 Feb 2023 22:38:44 -0500 Subject: [PATCH] Seller Filtering --- lib/meetings.dart | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/meetings.dart b/lib/meetings.dart index f09c4e6..1b094cb 100644 --- a/lib/meetings.dart +++ b/lib/meetings.dart @@ -9,22 +9,29 @@ class TimeRange { TimeRange(this.startTime, this.endTime); } +class PriceRange { + int low = 0; + int high = 0; + + PriceRange(this.low, this.high); +} + class Seller { String name = ""; String uid = ""; - String location = ""; + List location; TimeRange availableTime; - Int64 price; + int price; Seller(this.name, this.uid, this.location, this.availableTime, this.price); } class Filter { - String? location; - Int64? price; + List? locations; + PriceRange? price; TimeRange? meetingTime; - Filter(this.location, this.price, this.meetingTime); + Filter(this.locations, this.price, this.meetingTime); } Future> getSellers(Filter filter) async { @@ -32,8 +39,10 @@ Future> getSellers(Filter filter) async { List sellers = List.empty(); final Query query = users - .where('location', isEqualTo: filter.location) - .where('price', isEqualTo: filter.price) + .where('location', arrayContainsAny: filter.locations) + .where('price', + isGreaterThanOrEqualTo: filter.price?.low, + isLessThanOrEqualTo: filter.price?.high) .where('start-time', isGreaterThanOrEqualTo: filter.meetingTime?.startTime) .where('end-time', isLessThanOrEqualTo: filter.meetingTime?.endTime);