mirror of
https://github.com/SoPat712/RUSwipeShare.git
synced 2025-08-22 03:18:44 -04:00
Seller Filtering
This commit is contained in:
@@ -9,22 +9,29 @@ class TimeRange {
|
|||||||
TimeRange(this.startTime, this.endTime);
|
TimeRange(this.startTime, this.endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PriceRange {
|
||||||
|
int low = 0;
|
||||||
|
int high = 0;
|
||||||
|
|
||||||
|
PriceRange(this.low, this.high);
|
||||||
|
}
|
||||||
|
|
||||||
class Seller {
|
class Seller {
|
||||||
String name = "";
|
String name = "";
|
||||||
String uid = "";
|
String uid = "";
|
||||||
String location = "";
|
List<String> location;
|
||||||
TimeRange availableTime;
|
TimeRange availableTime;
|
||||||
Int64 price;
|
int price;
|
||||||
|
|
||||||
Seller(this.name, this.uid, this.location, this.availableTime, this.price);
|
Seller(this.name, this.uid, this.location, this.availableTime, this.price);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Filter {
|
class Filter {
|
||||||
String? location;
|
List<String>? locations;
|
||||||
Int64? price;
|
PriceRange? price;
|
||||||
TimeRange? meetingTime;
|
TimeRange? meetingTime;
|
||||||
|
|
||||||
Filter(this.location, this.price, this.meetingTime);
|
Filter(this.locations, this.price, this.meetingTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Seller>> getSellers(Filter filter) async {
|
Future<List<Seller>> getSellers(Filter filter) async {
|
||||||
@@ -32,8 +39,10 @@ Future<List<Seller>> getSellers(Filter filter) async {
|
|||||||
List<Seller> sellers = List.empty();
|
List<Seller> sellers = List.empty();
|
||||||
|
|
||||||
final Query query = users
|
final Query query = users
|
||||||
.where('location', isEqualTo: filter.location)
|
.where('location', arrayContainsAny: filter.locations)
|
||||||
.where('price', isEqualTo: filter.price)
|
.where('price',
|
||||||
|
isGreaterThanOrEqualTo: filter.price?.low,
|
||||||
|
isLessThanOrEqualTo: filter.price?.high)
|
||||||
.where('start-time',
|
.where('start-time',
|
||||||
isGreaterThanOrEqualTo: filter.meetingTime?.startTime)
|
isGreaterThanOrEqualTo: filter.meetingTime?.startTime)
|
||||||
.where('end-time', isLessThanOrEqualTo: filter.meetingTime?.endTime);
|
.where('end-time', isLessThanOrEqualTo: filter.meetingTime?.endTime);
|
||||||
|
Reference in New Issue
Block a user