resolveMetaDateResults method
Typically, the user types in a query, like "week before birthday", the system extracts "Birthday", constructs a query that can be sent to the server to be resolved. In the case of default values, we don't need to do the extra interpolation because we the source of the query is the date itself.constructed the query to be the date exactly.
Implementation
Future<List<SmartDateQueryResult>> resolveMetaDateResults(
{required Iterable<MetaDateRef> refs,
IRef? contact,
FutureOr<List<IFact>>? facts,
Location? location}) async {
try {
final _facts = await facts!;
final Iterable<FactDateSchemaQuery> matches =
(await factService.resolveMetaDates(refs)).map((_) => _.toQuery());
final Iterable<SmartDateQueryResult> metaDateMatches = matches.expand(
(match) {
return _resolveFactDates(
metaDate: match,
location: location,
facts: _facts,
contact: contact)
.map((contactFactResult) =>
contactFactResult.toSingleQueryResult())
.ifEmpty(() => [
UnresolvedFactDateQueryResult.ofSchemaQuery(match, contact!)
]);
},
);
return [...metaDateMatches];
} catch (e) {
log.severe("Error fetching date results $e", e);
rethrow;
}
}