Gitter migration: Setup redirects (rollout pt. 3)
[gitter.git] / server / services / explore-service.js
blobfc00d5e92f646fa85e22f3eec87030350bbbda8f
1 'use strict';
3 var persistence = require('gitter-web-persistence');
4 var cacheWrapper = require('gitter-web-cache-wrapper');
6 /**
7 * fetchByTags() retrives rooms that match a given set of tags
9 * tags Array the querying tags
10 * @return Promise promise of matching rooms
12 function fetchByTags(tags) {
13 // limit by 8 tags to avoid mega queries
14 tags = tags.slice(0, 8);
16 return persistence.Troupe.find({
17 'sd.public': true,
18 tags: {
19 $in: tags
22 .sort({ userCount: -1 })
23 .limit(50)
24 .exec();
27 exports.fetchByTags = fetchByTags;
29 exports.fetchByTagsCached = cacheWrapper('fetchByTagsCached', fetchByTags);