Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Optionally filter stories by idea.

  • Loading branch information...
commit 3eb7fdb1b835c73d28743e09c7db191fef31dfc4 1 parent fe7366f
@mike-burns authored
Showing with 20 additions and 10 deletions.
  1. +10 −2 FindStory.hs
  2. +10 −8 Trajectory/Private.hs
View
12 FindStory.hs
@@ -28,8 +28,10 @@ main = do
potentiallyAllStories <- (getAllStories config) :: IO (Either Error Stories)
case potentiallyAllStories of
(Left error) -> print error
- (Right allStories) ->
- putStrLn $ intercalate "\n\n" $ map formatStory $ getStories allStories
+ (Right allStories) -> do
+ let idea = ideaLimitationFrom specificArgs
+ stories = filterByIdea idea $ getStories allStories
+ putStrLn $ intercalate "\n\n" $ map formatStory stories
formatStory story =
title ++ "\n"
@@ -52,6 +54,12 @@ allStoriesUrl config = do
let key = getConfigKey config
return $ "https://www.apptrajectory.com/api/" ++ key ++ "/accounts/923bc9b85eaa4a9213c5/projects/activeblueleaf/stories.json"
+ideaLimitationFrom args = args `elementAfter` "--idea"
+
+filterByIdea Nothing stories = stories
+filterByIdea (Just ideaSubject) stories =
+ filter (maybe False (ideaSubject ==) . storyIdeaSubject) stories
+
deriving instance Eq Network.HTTP.Enumerator.HttpException
data Error =
View
18 Trajectory/Private.hs
@@ -32,14 +32,6 @@ mkConfig map args =
where
profileName = fromMaybe "default" $ args `elementAfter` "--profile"
- elementAfter [] _ = Nothing
- elementAfter (x:xs) match
- | x == match = nextElement xs
- | otherwise = elementAfter xs match
- where
- nextElement [] = Nothing
- nextElement (result:_) = Just result
-
getConfig args = do
configFileName <- getConfigFileName
jsonString <- BS.readFile configFileName
@@ -58,3 +50,13 @@ getConfigFileName = do
where
withHomeDir homeDir = homeDir ++ "/.trajectory"
withUserName userName = "/usr/"++userName++"/.trajectory"
+
+-- this is pretty generic:
+
+elementAfter [] _ = Nothing
+elementAfter (x:xs) match
+ | x == match = nextElement xs
+ | otherwise = elementAfter xs match
+ where
+ nextElement [] = Nothing
+ nextElement (result:_) = Just result
Please sign in to comment.
Something went wrong with that request. Please try again.