|
|
|
/**
|
|
|
|
* UserActivityController
|
|
|
|
*
|
|
|
|
* @description :: Server-side logic for managing useractivities
|
|
|
|
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
|
|
|
|
*/
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
|
|
|
search: function(req, res) {
|
|
|
|
var word = req.param('query'),
|
|
|
|
refQuery = UserActivity.find();
|
|
|
|
|
|
|
|
if (word != undefined)
|
|
|
|
refQuery = UserActivity.find({
|
|
|
|
where: {
|
|
|
|
or: [
|
|
|
|
{team: word},
|
|
|
|
{username: word}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
sort: {
|
|
|
|
date: 1
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
page = ((req.query.page != undefined) ? +req.query.page : 1);
|
|
|
|
refQuery.paginate({page: page, limit: 10}).exec(function(err, items) {
|
|
|
|
if (err) {
|
|
|
|
res.send(400);
|
|
|
|
} else {
|
|
|
|
res.send(items);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
jarvisid: function(req, res) {
|
|
|
|
var word = req.param('query'),
|
|
|
|
_options = {},
|
|
|
|
_count, query;
|
|
|
|
|
|
|
|
if (word != undefined) {
|
|
|
|
_options['jarvisId'] = word;
|
|
|
|
}
|
|
|
|
_options['sort'] = {date: -1};
|
|
|
|
|
|
|
|
query = UserActivity.find(_options);
|
|
|
|
page = ((req.query.page != undefined) ? +req.query.page : 1);
|
|
|
|
UserActivity.count(_options).exec(function(err, total) {
|
|
|
|
if (err)
|
|
|
|
res.send(400);
|
|
|
|
|
|
|
|
query.paginate({page: page, limit: 10}).populate('revision').exec(function(err, items) {
|
|
|
|
if (err) {
|
|
|
|
res.send(400);
|
|
|
|
} else {
|
|
|
|
res.send({count: total, results: items});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
oneteam: function(req, res) {
|
|
|
|
var teamQ = req.param('team'),
|
|
|
|
_options = {},
|
|
|
|
_count, query;
|
|
|
|
|
|
|
|
if (teamQ != undefined)
|
|
|
|
_options['team'] = teamQ;
|
|
|
|
_options['sort'] = {date: -1};
|
|
|
|
|
|
|
|
query = UserActivity.find(_options);
|
|
|
|
page = ((req.query.page != undefined) ? +req.query.page : 1);
|
|
|
|
UserActivity.count(_options).exec(function(err, total) {
|
|
|
|
if (err)
|
|
|
|
res.send(400);
|
|
|
|
|
|
|
|
query.paginate({page: page, limit: 10}).populate('revision').exec(function(err, items) {
|
|
|
|
if (err) {
|
|
|
|
res.send(400);
|
|
|
|
} else {
|
|
|
|
res.send({count: total, results: items});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
oneuser: function(req, res) {
|
|
|
|
var teamQ = req.param('team'),
|
|
|
|
usernameQ = req.param('username'),
|
|
|
|
_options = {},
|
|
|
|
_count, query;
|
|
|
|
|
|
|
|
if ((teamQ != undefined) && (usernameQ != undefined))
|
|
|
|
_options = {team: teamQ, username: usernameQ};
|
|
|
|
_options['sort'] = {date: -1};
|
|
|
|
|
|
|
|
query = UserActivity.find(_options);
|
|
|
|
page = ((req.query.page != undefined) ? +req.query.page : 1);
|
|
|
|
UserActivity.count(_options).exec(function(err, total) {
|
|
|
|
if (err)
|
|
|
|
res.send(400);
|
|
|
|
|
|
|
|
query.paginate({page: page, limit: 10}).populate('revision').exec(function(err, items) {
|
|
|
|
if (err) {
|
|
|
|
res.send(400);
|
|
|
|
} else {
|
|
|
|
res.send({count: total, results: items});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|