-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c5b0b4
commit c378786
Showing
3 changed files
with
23 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
import moment from 'moment'; | ||
|
||
export const getSprint = (project) => { | ||
const startDate = moment(new Date(project.startDate)); | ||
const weeks = moment().diff(startDate, 'week'); | ||
const sprintNumber = Math.ceil(weeks / project.iterationLength); | ||
return project.iterationLength > weeks ? sprintNumber : sprintNumber + 1; | ||
} | ||
const weeksBetween = (dateA, dateB) => | ||
moment(new Date(dateA)).diff(moment(new Date(dateB)), 'week'); | ||
|
||
const getIterationForDate = (date, project) => { | ||
const weeks = weeksBetween(date, project.startDate); | ||
const iterationQuantity = Math.ceil(weeks / project.iterationLength); | ||
|
||
return project.iterationLength > weeks ? iterationQuantity : iterationQuantity + 1; | ||
}; | ||
|
||
export const getCurrentIteration = (project) => ( | ||
getIterationForDate(new Date(), project) | ||
); | ||
|
||
export const getIterationForStory = (story, project) => { | ||
if(story.state === 'accepted') { | ||
const weeks = moment().diff(new Date(story.acceptedAt), 'week'); | ||
const sprintNumber = Math.ceil(weeks / project.iterationLength); | ||
return project.iterationLength > weeks ? sprintNumber : sprintNumber + 1; | ||
if (story.state === 'accepted') { | ||
return getIterationForDate(new Date(story.acceptedAt), project); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters