Browse Source

add controller for jarvis mk1

master
sipp11 9 years ago
parent
commit
9e955e74f1
  1. 28
      api/controllers/ObjReferenceController.js
  2. 64
      api/controllers/ObjRevisionController.js
  3. 71
      api/controllers/UserActivityController.js
  4. 15
      config/policies.js
  5. 7
      config/routes.js

28
api/controllers/ObjReferenceController.js

@ -7,5 +7,33 @@
module.exports = { module.exports = {
search: function(req, res) {
var word = req.param('query'),
refQuery = ObjReference.find();
if (word != undefined)
refQuery = ObjReference.find({
where: {
or: [
{team: word},
{type: word},
{bbApi: word},
{id: word},
]
},
sort: {
date: 1
}
});
refQuery.limit(10).exec(function(err, items) {
if (err) {
res.send(400);
} else {
res.send(items);
}
});
}
}; };

64
api/controllers/ObjRevisionController.js

@ -7,5 +7,69 @@
module.exports = { module.exports = {
search: function(req, res) {
var word = req.param('query'),
revisionQuery = ObjRevision.find();
if (word != undefined)
revisionQuery = ObjRevision.find({
where: {
or: [
{obj: {jarvisId: {contains: word}}},
{obj: {bbApi: {contains: word}}}
]
},
sort: {
date: 1
}
});
revisionQuery.limit(10).exec(function(err, items) {
if (err) {
res.send(400);
} else {
res.send(items);
}
});
},
jarvisid: function(req, res) {
var word = req.param('query'),
revisionQuery = ObjRevision.find();
if (word != undefined)
revisionQuery = ObjRevision.find({
jarvisId: word,
sort: { date: 1}
});
revisionQuery.limit(10).exec(function(err, items) {
if (err) {
res.send(400);
} else {
res.send(items);
}
});
},
bbapi: function(req, res) {
var word = req.param('query'),
revisionQuery = ObjRevision.find();
if (word != undefined)
revisionQuery = ObjRevision.find({
bbApi: word,
sort: { date: 1}
});
revisionQuery.limit(10).exec(function(err, items) {
if (err) {
res.send(400);
} else {
res.send(items);
}
});
}
}; };

71
api/controllers/UserActivityController.js

@ -7,5 +7,76 @@
module.exports = { 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);
}
});
}
}; };

15
config/policies.js

@ -45,6 +45,21 @@ module.exports.policies = {
'find': true, 'find': true,
'search': true, 'search': true,
}, },
'objrevision': {
'*': 'sessionAuth',
'search': true,
'jarvisid': true,
'bbapi': true,
},
'objreference': {
'*': 'sessionAuth',
'search': true,
},
'useractivity': {
'*': 'sessionAuth',
'oneteam': true,
'oneuser': true,
},
/*************************************************************************** /***************************************************************************
* * * *

7
config/routes.js

@ -48,5 +48,12 @@ module.exports.routes = {
'GET /nationality/search/:query': 'NationalityController.search', 'GET /nationality/search/:query': 'NationalityController.search',
'GET /flag/search/:query': 'FlagController.search', 'GET /flag/search/:query': 'FlagController.search',
'GET /prefix/search/:query': 'PrefixController.search', 'GET /prefix/search/:query': 'PrefixController.search',
'GET /objreference/search/:query': 'ObjReferenceController.search',
'GET /useractivity/search/:query': 'UserActivityController.search',
'GET /useractivity/u/:team': 'UserActivityController.oneteam',
'GET /useractivity/u/:team/:username': 'UserActivityController.oneuser',
'GET /objrevision/jarvisid/:query': 'ObjRevisionController.jarvisid',
'GET /objrevision/bbapi/:query': 'ObjRevisionController.bbapi',
}; };

Loading…
Cancel
Save