On Tue, Aug 04, 2015 at 03:39:27PM +0200, 'Klaus Aehlig' via ganeti-devel wrote:
When collecting live data for queries, we need to also
collect the fields the filter talks about, not only the
fields the user wants to see. Therefore, we need a function
computing those fields.

Signed-off-by: Klaus Aehlig <[email protected]>
---
src/Ganeti/Query/Language.hs | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/src/Ganeti/Query/Language.hs b/src/Ganeti/Query/Language.hs
index 2d23ff4..5a5f5aa 100644
--- a/src/Ganeti/Query/Language.hs
+++ b/src/Ganeti/Query/Language.hs
@@ -36,6 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

module Ganeti.Query.Language
    ( Filter(..)
+    , filterArguments
    , FilterField
    , FilterValue(..)
    , FilterRegex -- note: we don't export the constructor, must use helpers
@@ -191,6 +192,12 @@ data Filter a
    | ContainsFilter a FilterValue  -- ^ @=[]@ /list-field/ /value/
      deriving (Show, Eq)

+-- | Get the \"things\" a filter talks about. This is useful, e.g.,
+-- to decide which additional fields to fetch in a query depending
+-- on live data.
+filterArguments :: Filter a -> [a]
+filterArguments = fold . fmap return

This could be simplified to just 'toList' from Foldable.

+
-- | Serialiser for the 'Filter' data type.
showFilter :: (JSON a) => Filter a -> JSValue
showFilter (EmptyFilter)          = JSNull
--
2.5.0.rc2.392.g76e840b


Rest LGTM, no need to resend.

Reply via email to