This is a supporter for getblackboard.com; mainly for static API services. Let's see if this evolves into something else or not.
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.
 
 
 
 

118 lines
2.8 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
}
});
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});
}
});
});
}
};