diff --git a/controllers/people.js b/controllers/people.js
index e6539df7..794868f6 100644
--- a/controllers/people.js
+++ b/controllers/people.js
@@ -12,7 +12,8 @@ module.exports = {
collectUserPlaylists,
collectUserPlays,
collectPlayStats,
- collectArtistData
+ collectArtistData,
+ collectRooms
], function(err, results) {
var playlists = results[0];
@@ -40,6 +41,7 @@ module.exports = {
, artist: (results[3]) ? results[3].artist : null
, tracks: (results[3]) ? results[3].tracks : null
, trackCount: (results[3]) ? results[3].trackCount : null
+ , topRoomsByQueues: results[4]
});
if (req.app.config.jobs && req.app.config.jobs.enabled) {
@@ -52,6 +54,30 @@ module.exports = {
}
});
+
+ function collectRooms(done) {
+ Play.aggregate([
+ { $match: {
+ _curator: person._id
+ } },
+ { $group: { _id: '$_room', count: { $sum: 1 } } },
+ { $sort: { 'count': -1 } },
+ { $limit: LIMIT }
+ ], function(err, collected) {
+ Room.populate( collected , {
+ path: '_id'
+ }, function(err, topRooms) {
+ topRooms = topRooms.map(function(x) {
+ return {
+ _room: x._id,
+ count: x.count
+ };
+ });
+
+ done( null , topRooms );
+ });
+ });
+ }
function collectUserPlays(done) {
Play.find({ _curator: person._id }).sort('-timestamp').limit(20).populate('_track _curator _room').exec(function(err, plays) {
diff --git a/views/person.jade b/views/person.jade
index d8dd0694..beceef54 100644
--- a/views/person.jade
+++ b/views/person.jade
@@ -66,6 +66,8 @@ block content
a(href="#sets", data-toggle="tab") Sets
if (artist)
| /Albums
+ li
+ a(href="#rooms", data-toggle="tab") Rooms
li
a(href="#plays", data-toggle="tab") Plays
@@ -162,7 +164,15 @@ block content
i.icon-remove
a.btn.btn-mini(href="#", data-action="queue-set", data-set-slug="#{playlist._creator.slug}/#{playlist.slug}") ♫ queue »
-
+ .tab-pane#rooms
+ h3 Rooms
+
+ .row-fluid
+ .span6
+ h4 Most Queues
+ each room in topRoomsByQueues
+ li queued #{room.count} tracks in
+ a(href="#{room._room.index}") #{room._room.name}
.tab-pane#plays
h3 Recent Plays (view all »)