You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.6 KiB
82 lines
1.6 KiB
/** |
|
* 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).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).exec(function(err, items) { |
|
if (err) { |
|
res.send(400); |
|
} else { |
|
res.send(items); |
|
} |
|
}); |
|
} |
|
|
|
|
|
}; |
|
|
|
|