packages feed

bugzilla 0.2.0.0 → 0.2.1.0

raw patch · 5 files changed

+63/−6 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Web.Bugzilla: searchBugs' :: BugzillaSession -> SearchExpression -> IO [BugId]
+ Web.Bugzilla: searchBugsWithLimit' :: BugzillaSession -> Int -> Int -> SearchExpression -> IO [BugId]

Files

bugzilla.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                bugzilla-version:             0.2.0.0+version:             0.2.1.0 synopsis:            A Haskell interface to the Bugzilla native REST API description:         This package is designed to provide an easy-to-use, typesafe                      interface to querying Bugzilla from Haskell.@@ -21,7 +21,7 @@ source-repository head   type:     git   location: https://github.com/sethfowler/hsbugzilla.git-  tag:      0.2+  tag:      0.2.1  flag BuildDemo   description:  Build the 'bugzilla' demo program
changelog view
@@ -1,7 +1,13 @@+0.2.1.0++	* Added searchBugs' and searchBugsWithLimit', variations which return+	only a list of BugIds. These are more suitable for polling than the+	existing functions.+ 0.2.0.0  	* History events now have a sequential id, just like comments. -	* When using an anonymous session, Bugzilla does not return email addresses for users.-	  To accomodate this, the User type now stores email addresses as type-	  'Maybe UserEmail'.+	* When using an anonymous session, Bugzilla does not return email+	addresses for users.  To accomodate this, the User type now stores email+	addresses as type 'Maybe UserEmail'.
demo/BugzillaDemo.hs view
@@ -20,6 +20,7 @@ dispatch Nothing s ("--login" : user : as)    = dispatch (Just $ T.pack user) s as dispatch l Nothing ("--server" : server : as) = dispatch l (Just $ T.pack server) as dispatch l s ["--assigned-to", user]          = withBz l s $ doAssignedTo (T.pack user)+dispatch l s ["--assigned-to-brief", user]    = withBz l s $ doAssignedToBrief (T.pack user) dispatch l s ["--requests", user]             = withBz l s $ doRequests (T.pack user) dispatch l s ["--history", bug, n]            = withBz l s $ doHistory (read bug) (read n) dispatch _ _ _                                = usage@@ -31,6 +32,7 @@      >> hPutStrLn stderr ""      >> hPutStrLn stderr "Bugzilla queries:"      >> hPutStrLn stderr "  --assigned-to [user email] - List bugs assigned to the user."+     >> hPutStrLn stderr "  --assigned-to [user email] - List bugs assigned to the user."      >> hPutStrLn stderr "  --requests [user email]    - List requests for the user."      >> hPutStrLn stderr "  --history [bug number] [n] - List the most recent 'n' changes to the bug." @@ -61,6 +63,12 @@     showBug (Bug {..}) = putStrLn $ show bugId ++ ": " ++ show bugSummary                                  ++ " [" ++ T.unpack bugStatus ++ ": " ++ T.unpack bugResolution ++ "] Updated: "                                  ++ show bugLastChangeTime++doAssignedToBrief :: UserEmail -> BugzillaSession -> IO ()+doAssignedToBrief user session = do+    let search = AssignedToField .==. user+    bugs <- searchBugs' session search+    mapM_ print bugs  doRequests :: UserEmail -> BugzillaSession -> IO () doRequests user session = do
src/Web/Bugzilla.hs view
@@ -35,7 +35,9 @@    -- * Querying Bugzilla , searchBugs+, searchBugs' , searchBugsWithLimit+, searchBugsWithLimit' , getBug , getAttachment , getAttachments@@ -120,7 +122,7 @@ intAsText :: Int -> T.Text intAsText = T.pack . show --- | Search Bugzilla and returns a list of 'Bug's. The 'SearchExpression'+-- | Searches Bugzilla and returns a list of 'Bug's. The 'SearchExpression' -- can be constructed conveniently using the operators in "Web.Bugzilla.Search". searchBugs :: BugzillaSession -> SearchExpression -> IO [Bug] searchBugs session search = do@@ -129,6 +131,20 @@   (BugList bugs) <- sendBzRequest session req   return bugs +-- | Like 'searchBugs', but returns a list of 'BugId's. You can+-- retrieve the 'Bug' for each 'BugId' using 'getBug'. The combination+-- of 'searchBugs'' and 'getBug' is much less efficient than+-- 'searchBugs'. 'searchBugs'' is suitable for cases where you won't need to call+-- 'getBug' most of the time - for example, polling to determine whether the+-- set of bugs returned by a query has changed.+searchBugs' :: BugzillaSession -> SearchExpression -> IO [BugId]+searchBugs' session search = do+  let fieldsQuery = [("include_fields", Just "id")]+      searchQuery = evalSearchExpr search+      req = newBzRequest session ["bug"] (fieldsQuery ++ searchQuery)+  (BugIdList bugs) <- sendBzRequest session req+  return bugs+ -- | Search Bugzilla and returns a limited number of results. You can --   call this repeatedly and use 'offset' to retrieve the results of --   a large query incrementally. Note that most Bugzillas won't@@ -146,6 +162,22 @@       searchQuery = evalSearchExpr search       req = newBzRequest session ["bug"] (limitQuery ++ searchQuery)   (BugList bugs) <- sendBzRequest session req+  return bugs++-- | Like 'searchBugsWithLimit', but returns a list of 'BugId's. See+-- 'searchBugs'' for more discussion.+searchBugsWithLimit' :: BugzillaSession+                     -> Int  -- ^ The maximum number of results to return.+                     -> Int  -- ^ The offset from the first result to start from.+                     -> SearchExpression+                     -> IO [BugId]+searchBugsWithLimit' session limit offset search = do+  let fieldsQuery = [("include_fields", Just "id")]+      limitQuery = [("limit", Just $ intAsText limit),+                    ("offset", Just $ intAsText offset)]+      searchQuery = evalSearchExpr search+      req = newBzRequest session ["bug"] (fieldsQuery ++ limitQuery ++ searchQuery)+  (BugIdList bugs) <- sendBzRequest session req   return bugs  -- | Retrieve a bug by bug number.
src/Web/Bugzilla/Internal/Types.hs view
@@ -20,6 +20,7 @@ , Flag (..) , Bug (..) , BugList (..)+, BugIdList (..) , Attachment (..) , AttachmentList (..) , Comment (..)@@ -433,6 +434,16 @@  instance FromJSON BugList where   parseJSON (Object v) = BugList <$> v .: "bugs"+  parseJSON _          = mzero++data BugIdList = BugIdList [BugId]+                 deriving (Eq, Show)++instance FromJSON BugIdList where+  parseJSON (Object v) = do+    bugs <- v .: "bugs"+    bugIds <- mapM (.: "id") bugs+    return $ BugIdList bugIds   parseJSON _          = mzero  -- | An attachment to a bug.