             tempRes.push objected
             collectRelations objected
 
-  fetchReplies: (itemId, callback)->
-    query = """
-      start koding=node:koding("id:#{itemId}")
-      match koding-[r:reply]-all
-      return all, r
-      order by r.createdAtEpoch DESC
-      limit 2
-    """
+  fetchRelateds: (query, callback)->
     @db.query query, {}, (err, results) ->
       if err then callback err
       resultData = []

      return all, r
      order by r.createdAtEpoch DESC
    """
    @db.query query, {}, (err, results) ->
      if err then callback err
      resultData = []
      for result in results
        type = result.r.type
        data = result.all.data
        data.relationType = type
        resultData.push data

      objectify resultData, (objected)->
        respond = {}
        for obj in objected
          type = obj.relationType
          if not respond[type] then respond[type] = []
          respond[type].push obj

        callback err, respond

  fetchNewInstalledApps:(group, startDate, callback)->
    console.time 'fetchNewInstalledApps'


        callback err, respond


  fetchReplies: (itemId, callback)->
    query = """
      start koding=node:koding("id:#{itemId}")
      match koding-[r:reply]-all
      return all, r
      order by r.createdAtEpoch DESC
      limit 2
    """
    @fetchRelateds query, callback

  fetchRelatedItems:(itemId, callback)->
    query = """
      start koding=node:koding("id:#{itemId}")
