getAllFailedRequests function
returns a List of weird structures of the id of the failed request and a tuple where exactly one is null, either a http.Response or an http.MultipartRequest
Implementation
Future<List<(String, RequestData?)>?> getAllFailedRequests() async {
final docs = (await failedReqLogCollection
.get()); //TO-DO: das muss in-order sein, sonst könnte es probleme geben..
if (docs == null) return null;
final docsWithTimeStr =
docs.map((key, value) => MapEntry(key.split('/').last, value));
final docsWithTimeAsFutureTuples = docsWithTimeStr.entries.map((e) async {
try {
final parsedReq = RequestData.deserialize(e.value);
return (e.key, parsedReq);
} catch (err) {
debugPrint('failed parse of request hm, $err');
}
return (e.key, null);
});
var reqs = (await Future.wait(docsWithTimeAsFutureTuples));
reqs.sort((a, b) =>
int.parse(a.$1, radix: 36).compareTo(int.parse(b.$1, radix: 36)));
return reqs;
}