   #
   # Popularity is determined by number of entries in 'relationships'
   # collection that match the criteria passed to it.
-  @fetchItems = (name, options={}, callback) ->
+  @fetchItems = (options={}, callback) ->
+    {name}      = options
     mapping     = nameMapping[name]
     {klass, as} = mapping
 

  #   * Active topics in the last day
  #   * Random topics
  @fetchTopics = secure (client, options={}, callback)->
    @fetchItems "topic", options, callback

  # Returns users in following order:
  #   * Client's followers who are online
  #   * Active users in the last day
  #   * Random users
  @fetchUsers = secure (client, options={}, callback)->
    {delegate} = client.connection
    delegate._fetchMyOnlineFollowingsFromGraph client, {}, (err, onlineMembers)=>
      return callback err                 if err
      return callback null, onlineMembers if onlineMembers.length >= 10

      missing     = 10 - onlineMembers.length
      existingIds = onlineMembers.map (member)-> member._id

      @fetchItems "user", {count:missing, nin:existingIds}, (err, activeMembers)->
        return callback err  if err
        members = _.flatten activeMembers, onlineMembers
        callback null, members


JAccount       = require "./account"
JTag           = require "./tag"
Cache          = require "../cache/main"

{secure, daisy, Base} = Bongo

