From a7c63ab7c0d2c903a68323562f3915623bacd4c5 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Sat, 18 Apr 2020 18:05:49 -0400 Subject: [PATCH] Rename for clarity --- src/Neuron/CLI/Types.hs | 2 +- src/Neuron/Zettelkasten/Query.hs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Neuron/CLI/Types.hs b/src/Neuron/CLI/Types.hs index c3de6cea5..b1e5db8c1 100644 --- a/src/Neuron/CLI/Types.hs +++ b/src/Neuron/CLI/Types.hs @@ -94,7 +94,7 @@ commandParser defaultNotesDir = do pure Open queryCommand = fmap Query $ - many (Z.ByTag . Z.TagPattern <$> option str (long "tag" <> short 't')) + many (Z.Query_ZettelsByTag . Z.TagPattern <$> option str (long "tag" <> short 't')) <|> option uriReader (long "uri" <> short 'u') searchCommand = do searchBy <- diff --git a/src/Neuron/Zettelkasten/Query.hs b/src/Neuron/Zettelkasten/Query.hs index 0e25e06b8..bb7d0e382 100644 --- a/src/Neuron/Zettelkasten/Query.hs +++ b/src/Neuron/Zettelkasten/Query.hs @@ -18,16 +18,18 @@ import Neuron.Zettelkasten.Zettel import Relude import qualified Text.URI as URI +-- | Query represents a way to query the Zettelkasten. +-- -- TODO: Support querying connections, a la: -- LinksTo ZettelID -- LinksFrom ZettelID data Query - = ByTag TagPattern + = Query_ZettelsByTag TagPattern deriving (Eq, Show) instance ToHtml Query where toHtmlRaw = toHtml - toHtml (ByTag (TagPattern pat)) = + toHtml (Query_ZettelsByTag (TagPattern pat)) = let desc = "Zettels matching tag '" <> toText pat <> "'" in span_ [class_ "ui basic pointing below black label", title_ desc] $ toHtml pat @@ -46,13 +48,13 @@ queryFromURI uri = flip mapMaybe (URI.uriQuery uri) $ \case URI.QueryParam (URI.unRText -> key) (URI.unRText -> val) -> case key of - "tag" -> Just $ ByTag (TagPattern $ toString val) + "tag" -> Just $ Query_ZettelsByTag (TagPattern $ toString val) _ -> Nothing _ -> Nothing matchQuery :: Zettel -> Query -> Bool matchQuery Zettel {..} = \case - ByTag pat -> any (tagMatch pat) zettelTags + Query_ZettelsByTag pat -> any (tagMatch pat) zettelTags matchQueries :: Zettel -> [Query] -> Bool matchQueries zettel queries = and $ matchQuery zettel <$> queries