working backend code
This commit is contained in:
parent
adca39d2ed
commit
6062503c3b
|
@ -1,4 +0,0 @@
|
|||
InterMine Github Issues Burn down chart
|
||||
|
||||
## Why?
|
||||
* To measure how well we estimate the effort required to tackle tasks
|
67
app.coffee
67
app.coffee
|
@ -56,16 +56,77 @@ app.get '/burndown', (req, res) ->
|
|||
|
||||
# Are we done?
|
||||
if resources is 0
|
||||
# Convert GitHub ISO to JS ISO date and then time
|
||||
dateToTime = (date) -> new Date(date[0...date.length - 1] + '.000' + date.charAt date.length-1).getTime()
|
||||
|
||||
# Store the current milestone and its size.
|
||||
current = { 'milestone': {}, 'diff': +Infinity, 'size': 0 }
|
||||
|
||||
# Determine the 'current' milestone
|
||||
now = new Date().getTime() ; current = { 'data': {}, 'diff': +Infinity }
|
||||
now = new Date().getTime()
|
||||
for milestone in store.milestones
|
||||
due = milestone['due_on']
|
||||
# JS expects more accuracy.
|
||||
due = new Date(due[0...due.length - 1] + '.000' + due.charAt due.length-1).getTime()
|
||||
due = dateToTime due
|
||||
# Is this the 'current' one?
|
||||
diff = due - now
|
||||
if diff > 0 and diff < current.diff
|
||||
current.data = milestone ; current.diff = diff
|
||||
current.milestone = milestone ; current.diff = diff ; current.due = due
|
||||
|
||||
# Create n dict with all dates in the milestone span.
|
||||
days = {} ; totalDays = 0
|
||||
day = dateToTime current.milestone.created_at # TODO: shift this to the start of the day and deal with time shifts.
|
||||
while day < current.due
|
||||
# Save the day.
|
||||
days[day] = { 'issue': {}, 'actual': 0, 'ideal': 0 }
|
||||
# Shift by a day.
|
||||
day += 1000 * 60 * 60 * 24
|
||||
# Increase the total count.
|
||||
totalDays += 1
|
||||
|
||||
# Now go through the issues and place them to the appropriate days.
|
||||
for issue in store.issues
|
||||
# This milestone?
|
||||
if issue.milestone?.number is current.milestone.number
|
||||
# Has a size label?
|
||||
if issue.labels?
|
||||
issue.size = do (issue) ->
|
||||
for label in issue.labels
|
||||
if label.name.indexOf("size ") is 0
|
||||
return parseInt label.name[5...]
|
||||
|
||||
if issue.size?
|
||||
# Increase the total size of the milestone.
|
||||
current.size += issue.size
|
||||
# Is it closed?
|
||||
if issue.closed_at?
|
||||
closed = dateToTime issue.closed_at
|
||||
# Find when was it closed (will be made faster)
|
||||
day = do () ->
|
||||
for day, x of days
|
||||
if closed < day then return day
|
||||
|
||||
# Save it.
|
||||
if day? then days[day]['issue'] = issue
|
||||
|
||||
# Calculate the predicted daily velocity.
|
||||
dailyIdeal = current['size'] / totalDays ; ideal = current['size']
|
||||
|
||||
# Go through the days and save the number of outstanding issues size.
|
||||
for day, d of days
|
||||
# Does this day have an issue closed? Reduce the total for this milestone.
|
||||
if d['issue'].size? then current['size'] -= d['issue'].size
|
||||
# Save the oustanding count for that day.
|
||||
days[day].actual = current['size']
|
||||
# Save the predicted velocity for that day.
|
||||
ideal -= dailyIdeal
|
||||
days[day].ideal = ideal
|
||||
|
||||
# Finally send to client.
|
||||
res.render 'burndown',
|
||||
'days': days
|
||||
, (html) -> res.send html, 'Content-Type': 'text/html', 200
|
||||
|
||||
|
||||
# Get Milestones, Opened and Closed Tickets.
|
||||
apiGet "/repos/intermine/InterMine/milestones", 'milestones', done
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>Burndown App</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header class="navbar blue blue2 navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<ul class="nav pull-left">
|
||||
<li><a><i class="icon-white icon-fire"></i> Burndown App</a></li>
|
||||
</ul>
|
||||
<ul class="nav pull-right">
|
||||
<li><a><i class="icon-white icon-book"></i> Core InterMine Project</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="container-fluid pad40">
|
||||
<section class="row-fluid">
|
||||
<div class="span2 sideBar">
|
||||
<br>
|
||||
<ul>
|
||||
<li class="active">
|
||||
<figure>
|
||||
<i class="icon-signal"></i> Burndown Chart <span class="badge badge-warning">0.7</span>
|
||||
</figure>
|
||||
</li>
|
||||
<li>
|
||||
<figure>
|
||||
<i class="icon-tasks"></i> Issues <span class="badge badge-info">?</span>
|
||||
</figure>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<section class="span10 content borBox">
|
||||
<div class="row-fluid">
|
||||
<div class="page-header">
|
||||
<h1>Burndown chart <small>showing actual vs. ideal velocity on each day</small></h1>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
dd
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
|
@ -8,9 +8,6 @@
|
|||
|
||||
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/style.css">
|
||||
|
||||
<script src="js/jquery-1.7.2.min.js"></script>
|
||||
<script src="js/burndown.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header class="navbar blue blue2 navbar-fixed-top">
|
||||
|
|
Loading…
Reference in New Issue