aboutsummaryrefslogtreecommitdiffstats
path: root/app.coffee
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2012-11-12 23:25:09 -0800
committerAdam Soltys <[email protected]>2012-11-12 23:25:09 -0800
commit54c28a395db853c601d3592c967f322c7f09e1d4 (patch)
tree5e5ccd511daa0eabe82b5591298918c015d2eb14 /app.coffee
parent5bba3395bc0bb84dcd24a7ade0c855a6beb6dbef (diff)
downloadcoinos-server-54c28a395db853c601d3592c967f322c7f09e1d4.tar.gz
coinos-server-54c28a395db853c601d3592c967f322c7f09e1d4.zip
Making progress on transactions report
Diffstat (limited to 'app.coffee')
-rw-r--r--app.coffee20
1 files changed, 14 insertions, 6 deletions
diff --git a/app.coffee b/app.coffee
index d18ab470..cdc8c313 100644
--- a/app.coffee
+++ b/app.coffee
@@ -20,8 +20,8 @@ app.get('/', (req, res) ->
res.render('index', js: (-> global.js), css: (-> global.css))
)
-app.get('/report', (req, res) ->
- res.render('report', js: (-> global.js), css: (-> global.css))
+app.get('/:user/report', (req, res) ->
+ res.render('report', user: req.params.user, js: (-> global.js), css: (-> global.css))
)
app.get('/:user.json', (req, res) ->
@@ -35,16 +35,24 @@ app.get('/:user.json', (req, res) ->
app.get('/:user/transactions', (req, res) ->
db = require("redis").createClient()
user = req.params.user
+ r = 'transactions': []
db.lrange("#{user}:transactions", 0, -1, (err, transactions) ->
- for i in transactions
- db.hgetall("#{user}:transactions:#{i}", (err, t) ->
- res.write(JSON.stringify(t))
+ process = (err, t) ->
+ r.transactions.push t
+
+ if i >= transactions.length
+ res.write(JSON.stringify(r))
res.end()
- )
+ else
+ db.hgetall("#{user}:transactions:#{transactions[i++]}", process)
+
+ i = 0
+ db.hgetall("#{user}:transactions:#{transactions[i++]}", process)
)
)
+
app.get('/ticker', (req, res) ->
symbol = req.params.symbol
symbol or= 'virtexCAD'