Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Only show stories from the current iteration.

  • Loading branch information...
commit 23c80d7821b4d30c3a8cdd6a2a7115ec9eaf4a13 1 parent 049f8b8
Mike Burns authored
Showing with 60 additions and 11 deletions.
  1. +13 −6 LsStory.hs
  2. +27 −5 Trajectory/Private/API.hs
  3. +20 −0 Trajectory/Types.hs
19 LsStory.hs
View
@@ -10,7 +10,7 @@ import Control.Applicative( (<*>) )
import Data.Monoid (mconcat)
import Trajectory.Private.Config (withKey)
-import Trajectory.Private.API (getStories, Story(..))
+import Trajectory.Private.API (getStories, Story(..), Iteration(..))
main = do
args <- cmdArgs lsStoryArgDefinition
@@ -20,9 +20,9 @@ main = do
(handle args)
stories
-handle :: LsStoryArg -> [Story] -> String
-handle args stories =
- let filters = buildFilters args
+handle :: LsStoryArg -> ([Story],[Iteration]) -> String
+handle args (stories,iterations) =
+ let filters = buildFilters args iterations
renderer = buildRenderer args in
renderer $ filters `pipe` stories
where
@@ -64,8 +64,8 @@ milestonePrefix story
| storyTaskType story == "Milestone" = "^^^ "
| otherwise = ""
-buildFilters :: LsStoryArg -> [ [Story] -> [Story] ]
-buildFilters args = filters <*> [args]
+buildFilters :: LsStoryArg -> [Iteration] -> [ [Story] -> [Story] ]
+buildFilters args iterations = filters <*> [args]
where filters = [
ideaFilter
,beforeMilestoneFilter
@@ -73,6 +73,7 @@ buildFilters args = filters <*> [args]
,assignmentFilter
,stateFilter
,neededFilter
+ ,iterationFilter iterations
,deletionsFilter
]
@@ -142,6 +143,12 @@ neededFilter args
| showDevelopmentNeeded args = filter storyDevelopmentNeeded
| otherwise = id
+iterationFilter iterations args =
+ filter ((currentIterationId ==) . storyIterationId)
+ where
+ currentIteration = head $ filter iterationIsCurrent iterations
+ currentIterationId = iterationId currentIteration
+
deletionsFilter args = filter (not . storyDeleted)
data LsStoryArg = LsStoryArg {
32 Trajectory/Private/API.hs
View
@@ -21,7 +21,8 @@ import Data.Maybe (fromMaybe)
import Trajectory.Types
-data Stories = Stories [Story] deriving (Show, Eq, Typeable, Data)
+data Stories = Stories [Story] [Iteration]
+ deriving (Show, Eq, Typeable, Data)
instance FromJSON Story where
parseJSON (Object o) =
@@ -49,12 +50,33 @@ instance FromJSON Story where
<*> o .:? "idea_subject"
parseJSON _ = fail "Could not build a Story"
+instance FromJSON Iteration where
+ parseJSON (Object o) =
+ Iteration <$> o .: "accepted_points"
+ <*> o .: "complete"
+ <*> o .: "created_at"
+ <*> o .: "estimated_points"
+ <*> o .: "estimated_velocity"
+ <*> o .: "id"
+ <*> o .: "starts_on"
+ <*> o .: "stories_count"
+ <*> o .: "team_strength"
+ <*> o .: "updated_at"
+ <*> o .: "percent_complete"
+ <*> o .: "current?"
+ <*> o .: "unstarted_stories_count"
+ <*> o .: "accepted_stories_count"
+ <*> o .: "started_stories_count"
+ <*> o .: "delivered_stories_count"
+ <*> o .: "comments_count"
+ parseJSON _ = fail "Could not build an Iteration"
+
instance FromJSON Stories where
parseJSON (Object o) =
- Stories <$> o .: "stories"
+ Stories <$> o .: "stories" <*> o .: "iterations"
parseJSON _ = fail "Could not build Stories"
-getStories :: String -> String -> String -> IO (Either Error [Story])
+getStories :: String -> String -> String -> IO (Either Error ([Story], [Iteration]))
getStories key accountName projectName = do
let url = buildUrl [key, "accounts", accountName, "projects", projectName, "stories.json"]
result <- doHttps (BS.pack "GET") url Nothing
@@ -62,9 +84,9 @@ getStories key accountName projectName = do
(extractStories . parseJson . responseBody)
result
where
- extractStories :: (Either Error Stories) -> (Either Error [Story])
+ extractStories :: (Either Error Stories) -> (Either Error ([Story],[Iteration]))
extractStories (Left l) = Left l
- extractStories (Right (Stories ss)) = Right ss
+ extractStories (Right (Stories stories iterations)) = Right (stories, iterations)
buildUrl :: [String] -> String
20 Trajectory/Types.hs
View
@@ -37,3 +37,23 @@ data Story = Story {
,storyStateEvents :: [String]
,storyIdeaSubject :: Maybe String
} deriving (Show, Eq, Typeable, Data)
+
+data Iteration = Iteration {
+ iterationAcceptedPoints :: Int
+ ,iterationIsComplete :: Bool
+ ,iterationCreatedAt :: String
+ ,iterationEstimatedPoints :: Int
+ ,iterationEstimatedVelocity :: Int
+ ,iterationId :: Int
+ ,iterationStartsOn :: String
+ ,iterationStoriesCount :: Int
+ ,iterationTeamStrength :: Int
+ ,iterationUpdatedAt :: String
+ ,iterationPercentComplete :: Int
+ ,iterationIsCurrent :: Bool
+ ,iterationUnstartedStoriesCount :: Int
+ ,iterationAcceptedStoriesCount :: Int
+ ,iterationStartedStoriesCount :: Int
+ ,iterationDeliveredStoriesCount :: Int
+ ,iterationCommentsCount :: Int
+} deriving (Show, Eq, Typeable, Data)
Please sign in to comment.
Something went wrong with that request. Please try again.