-function removeAll (callback) {
- this.remove({ }, callback)
+ Pod.listRandomPodIdsWithRequest(limitPods, function (err, podIds) {
+ if (err) return callback(err)
+
+ // We don't have friends that have requests
+ if (podIds.length === 0) return callback(null, [])
+
+ // The the first x requests of these pods
+ // It is very important to sort by id ASC to keep the requests order!
+ const query = {
+ order: [
+ [ 'id', 'ASC' ]
+ ],
+ include: [
+ {
+ model: self.sequelize.models.Pod,
+ where: {
+ id: {
+ $in: podIds
+ }
+ }
+ }
+ ]
+ }
+
+ self.findAll(query).asCallback(function (err, requests) {
+ if (err) return callback(err)
+
+ const requestsGrouped = groupAndTruncateRequests(requests, limitRequestsPerPod)
+ return callback(err, requestsGrouped)
+ })
+ })