From 39823f8909e8113fdbe34bd9bf82190bee570ad4 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Fri, 8 Jul 2016 11:37:30 +0200 Subject: [PATCH] Add a pre_filtered_list method in collection. This allow filters optimizations --- radicale/storage.py | 9 +++++++++ radicale/xmlutils.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/radicale/storage.py b/radicale/storage.py index c50edf5..a54774f 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -231,6 +231,15 @@ class BaseCollection: for href in set(hrefs): yield self.get(href) + def pre_filtered_list(self, filters): + """List collection items with optional pre filtering. + + This could largely improve performance of reports depending on + the filters and this implementation. + This returns all event by default + """ + return [self.get(href) for href, _ in self.list()] + def has(self, href): """Check if an item exists by its href. diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index 71bb8a3..350dd1b 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -837,7 +837,7 @@ def report(path, xml_request, collection): else: # Reference is a collection path = hreference - items = [collection.get(href) for href, etag in collection.list()] + items = collection.pre_filtered_list(filters) for item in items: if filters: