               callback null, results.post
         async.map posts, downloadFullPost, callback
       (posts, callback) ->
+        now = Date.now()
+        console.log "#{now - start} (#{now - last}) to get full posts"
+        last = now
         sortPosts req.app.db, req.app.fuzzyIO, req.agent, posts, req.user, req.token, callback
     ], (err, posts) ->
       if err
         next err
       else
+        now = Date.now()
+        console.log "#{now - start} (#{now - last}) to sort posts"
+        last = now
         res.render 'home',
           posts: posts
           title: "Today's Posts"

            callback new Error("Bad status code #{response.statusCode} getting posts: #{body}")
          else
            results = JSON.parse(body)
            callback null, results.posts
      (posts, callback) ->
        downloadFullPost = (post, callback) ->

  url = 'https://api.producthunt.com/v1/oauth/authorize?' + qs.stringify(props)
  res.redirect url, 303

updateFollowing = (db, user, token, callback) ->

  following = []

  getNext = (oldest, callback) ->

    params =
      per_page: 100
      order: "desc"

    if oldest?
      params.older = oldest

    url = "https://api.producthunt.com/v1/users/#{user.id}/following?" + qs.stringify(params)

    web.get url, {Authorization: "Bearer #{token}"}, (err, response, body) ->
      if err
        callback err
      else if response.statusCode != 200
        callback new Error("Bad status code #{response.statusCode}: #{body}")
      else
        results = JSON.parse(body)
        page = _.pluck results.following, "id"
        users = _.pluck results.following, "user"
        userIDs = _.map(_.pluck(users, "id"), (id) -> parseInt(id, 10))
        if page.length > 0
          following = following.concat userIDs
          getNext page[page.length - 1], callback
        else
          callback null, _.uniq(following.sort())

  getNext null, (err, following) ->
    if err
      callback err
    else
      db.save "UserFollowing", user.id, following, callback

router.get '/authorized', (req, res, next) ->

  code = req.query.code
