sessionQuery method
List of Sessions matching the search criteria.
metaLike
will match against all key value pairs provided in a case
insensitve manner.
Implementation
// TODO: Add date filters
List<Session> sessionQuery({Map<String, String> metaLike = const {}}) {
List<Session> result = sessions;
if (metaLike.isNotEmpty) {
metaLike = metaLike.map((k, v) => MapEntry(k.toLowerCase(), v));
result = result.where((s) {
if (s.kvps.isEmpty) return false;
Map<String, String> lowerMeta =
s.kvps.map((k, v) => MapEntry(k.toLowerCase(), v));
bool match = false;
for (String key in lowerMeta.keys) {
if (match) break;
if (!metaLike.keys.contains(key)) continue;
match = (metaLike[key] ?? "NOPE").toLowerCase() ==
(lowerMeta[key] ?? "YUP").toLowerCase();
}
return match;
}).toList();
}
return result;
}