mirror of
https://github.com/status-im/burnchart.git
synced 2025-03-03 11:30:38 +00:00
we now have the nearest future deadline / milestone
This commit is contained in:
parent
516a1eac24
commit
adca39d2ed
48
app.coffee
48
app.coffee
@ -3,20 +3,22 @@ eco = require 'eco'
|
|||||||
https = require 'https'
|
https = require 'https'
|
||||||
fs = require "fs"
|
fs = require "fs"
|
||||||
|
|
||||||
options =
|
# Make HTTPS GET to GitHub API v3.
|
||||||
host: "api.github.com"
|
apiGet = (path, type, callback) ->
|
||||||
path: "/repos/intermine/InterMine/issues"
|
options =
|
||||||
method: "GET"
|
host: "api.github.com"
|
||||||
|
method: "GET"
|
||||||
|
path: path
|
||||||
|
|
||||||
getIssues = (callback) ->
|
|
||||||
https.request(options, (response) ->
|
https.request(options, (response) ->
|
||||||
if response.statusCode is 200
|
if response.statusCode is 200
|
||||||
json = ""
|
json = ""
|
||||||
response.on "data", (chunk) -> json += chunk
|
response.on "data", (chunk) -> json += chunk
|
||||||
|
|
||||||
response.on "end", -> callback JSON.parse json
|
response.on "end", -> callback JSON.parse(json), type
|
||||||
).end()
|
).end()
|
||||||
|
|
||||||
|
# Express.
|
||||||
app = express.createServer()
|
app = express.createServer()
|
||||||
|
|
||||||
app.configure ->
|
app.configure ->
|
||||||
@ -41,9 +43,39 @@ app.configure 'development', ->
|
|||||||
app.configure 'production', ->
|
app.configure 'production', ->
|
||||||
app.use express.errorHandler()
|
app.use express.errorHandler()
|
||||||
|
|
||||||
# Routes
|
# Show burndown chart.
|
||||||
|
app.get '/burndown', (req, res) ->
|
||||||
|
resources = 3 ; store = { 'issues': [], 'milestones': [] }
|
||||||
|
done = (data, type) ->
|
||||||
|
# One less to do.
|
||||||
|
resources--
|
||||||
|
|
||||||
|
switch type
|
||||||
|
when 'issues' then store.issues = store.issues.concat data
|
||||||
|
when 'milestones' then store.milestones = store.milestones.concat data
|
||||||
|
|
||||||
|
# Are we done?
|
||||||
|
if resources is 0
|
||||||
|
# Determine the 'current' milestone
|
||||||
|
now = new Date().getTime() ; current = { 'data': {}, 'diff': +Infinity }
|
||||||
|
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()
|
||||||
|
# Is this the 'current' one?
|
||||||
|
diff = due - now
|
||||||
|
if diff > 0 and diff < current.diff
|
||||||
|
current.data = milestone ; current.diff = diff
|
||||||
|
|
||||||
|
# Get Milestones, Opened and Closed Tickets.
|
||||||
|
apiGet "/repos/intermine/InterMine/milestones", 'milestones', done
|
||||||
|
apiGet "/repos/intermine/InterMine/issues?state=open", 'issues', done
|
||||||
|
apiGet "/repos/intermine/InterMine/issues?state=closed", 'issues', done
|
||||||
|
|
||||||
|
# Show open issues.
|
||||||
app.get '/issues', (req, res) ->
|
app.get '/issues', (req, res) ->
|
||||||
getIssues (issues) ->
|
apiGet "/repos/intermine/InterMine/issues?state=open", 'issues', (issues) ->
|
||||||
|
# Vanilla render.
|
||||||
res.render 'issues',
|
res.render 'issues',
|
||||||
'issues': issues
|
'issues': issues
|
||||||
, (html) -> res.send html, 'Content-Type': 'text/html', 200
|
, (html) -> res.send html, 'Content-Type': 'text/html', 200
|
||||||
|
Loading…
x
Reference in New Issue
Block a user