|
|
|
/**
|
|
|
|
* 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
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
refQuery.limit(10).exec(function(err, items) {
|
|
|
|
if (err) {
|
|
|
|
res.send(400);
|
|
|
|
} else {
|
|
|
|
res.send(items);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
oneteam: function(req, res) {
|
|
|
|
var teamQ = req.param('team'),
|
|
|
|
refQuery = UserActivity.find();
|
|
|
|
|
|
|
|
if (teamQ != undefined)
|
|
|
|
refQuery = UserActivity.find({
|
|
|
|
team: teamQ,
|
|
|
|
sort: {
|
|
|
|
date: -1
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
refQuery.limit(10).populate('jarvisId').exec(function(err, items) {
|
|
|
|
if (err) {
|
|
|
|
res.send(400);
|
|
|
|
} else {
|
|
|
|
res.send(items);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
oneuser: function(req, res) {
|
|
|
|
var teamQ = req.param('team'),
|
|
|
|
usernameQ = req.param('username'),
|
|
|
|
refQuery = UserActivity.find();
|
|
|
|
|
|
|
|
if ((teamQ != undefined) && (usernameQ != undefined))
|
|
|
|
refQuery = UserActivity.find({
|
|
|
|
team: teamQ,
|
|
|
|
username: usernameQ,
|
|
|
|
sort: {
|
|
|
|
date: -1
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
refQuery.limit(10).populate('jarvisId').exec(function(err, items) {
|
|
|
|
if (err) {
|
|
|
|
res.send(400);
|
|
|
|
} else {
|
|
|
|
res.send(items);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|