Skip to content

Commit

Permalink
Feature #53 Tracing
Browse files Browse the repository at this point in the history
UOA logs
  • Loading branch information
dtseytlin committed Mar 23, 2016
1 parent 069fa80 commit 0c7bec6
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 2 deletions.
23 changes: 23 additions & 0 deletions backend/app/controllers/uoaclasstypes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var client = require('app/db_bootstrap'),
_ = require('underscore'),
config = require('config'),
BoLogger = require('app/bologger'),
bologger = new BoLogger(),
UnitOfAnalysisClassType = require('app/models/uoaclasstypes'),
AccessMatrix = require('app/models/access_matrices'),
Translation = require('app/models/translations'),
Expand Down Expand Up @@ -58,6 +60,13 @@ module.exports = {
co(function* () {
return yield thunkQuery(UnitOfAnalysisClassType.insert(req.body).returning(UnitOfAnalysisClassType.id));
}).then(function (data) {
bologger.log({
user: req.user.id,
action: 'insert',
object: 'UnitOfAnalysisClassType',
entity: _.first(data).id,
info: 'Add new uoa class type'
});
res.status(201).json(_.first(data));
}, function (err) {
next(err);
Expand All @@ -68,6 +77,13 @@ module.exports = {
co(function* () {
return yield thunkQuery(UnitOfAnalysisClassType.update(req.body).where(UnitOfAnalysisClassType.id.equals(req.params.id)));
}).then(function () {
bologger.log({
user: req.user.id,
action: 'update',
object: 'UnitOfAnalysisClassType',
entity: req.params.id,
info: 'Update uoa class type'
});
res.status(202).end();
}, function (err) {
next(err);
Expand All @@ -78,6 +94,13 @@ module.exports = {
co(function* () {
return yield thunkQuery(UnitOfAnalysisClassType.delete().where(UnitOfAnalysisClassType.id.equals(req.params.id)));
}).then(function () {
bologger.log({
user: req.user.id,
action: 'delete',
object: 'UnitOfAnalysisClassType',
entity: req.params.id,
info: 'Delete uoa class type'
});
res.status(204).end();
}, function (err) {
next(err);
Expand Down
35 changes: 33 additions & 2 deletions backend/app/controllers/uoas.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var client = require('app/db_bootstrap'),
_ = require('underscore'),
config = require('config'),
BoLogger = require('app/bologger'),
bologger = new BoLogger(),
vl = require('validator'),
UnitOfAnalysis = require('app/models/uoas'),
UnitOfAnalysisType = require('app/models/uoatypes'),
Expand Down Expand Up @@ -60,9 +62,16 @@ module.exports = {
co(function* () {
req.body.creatorId = req.user.id;
req.body.ownerId = req.user.id;
req.body.createTime = new Date();
req.body.created = new Date();
return yield thunkQuery(UnitOfAnalysis.insert(req.body).returning(UnitOfAnalysis.id));
}).then(function (data) {
bologger.log({
user: req.user.id,
action: 'insert',
object: 'UnitOfAnalysis',
entity: _.first(data).id,
info: 'Add new uoa'
});
res.status(201).json(_.first(data));
}, function (err) {
next(err);
Expand All @@ -71,9 +80,17 @@ module.exports = {

updateOne: function (req, res, next) {
co(function* () {
delete req.body.createTime;
delete req.body.created;
req.body.updated = new Date();
return yield thunkQuery(UnitOfAnalysis.update(req.body).where(UnitOfAnalysis.id.equals(req.params.id)));
}).then(function () {
bologger.log({
user: req.user.id,
action: 'update',
object: 'UnitOfAnalysis',
entity: req.params.id,
info: 'Update uoa'
});
res.status(202).end();
}, function (err) {
next(err);
Expand All @@ -84,6 +101,13 @@ module.exports = {
co(function* () {
return yield thunkQuery(UnitOfAnalysis.delete().where(UnitOfAnalysis.id.equals(req.params.id)));
}).then(function () {
bologger.log({
user: req.user.id,
action: 'delete',
object: 'UnitOfAnalysis',
entity: req.params.id,
info: 'Delete uoa'
});
res.status(204).end();
}, function (err) {
next(err);
Expand Down Expand Up @@ -268,6 +292,13 @@ module.exports = {
newUoa.id = created[0].id;
newUoa.parse_status = 'Ok';
newUoa.messages.push('Added');
bologger.log({
user: req.user.id,
action: 'insert',
object: (!bologger.data.essence) ? 'UnitOfAnalysis' : null,
entity: created[0].id,
info: 'Add new uoa (bulk import)'
});
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions backend/app/controllers/uoataglinks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var client = require('app/db_bootstrap'),
_ = require('underscore'),
config = require('config'),
BoLogger = require('app/bologger'),
bologger = new BoLogger(),
UnitOfAnalysisTagLink = require('app/models/uoataglinks'),
UnitOfAnalysisTag = require('app/models/uoatags'),
UnitOfAnalysisClassType = require('app/models/uoaclasstypes'),
Expand Down Expand Up @@ -99,6 +101,13 @@ module.exports = {
co(function* () {
return yield thunkQuery(UnitOfAnalysisTagLink.insert(req.body).returning(UnitOfAnalysisTagLink.id));
}).then(function (data) {
bologger.log({
user: req.user.id,
action: 'insert',
object: 'UnitOfAnalysisTagLink',
entity: _.first(data).id,
info: 'Add new uoa tag link'
});
res.status(201).json(_.first(data));
}, function (err) {
next(err);
Expand All @@ -109,6 +118,13 @@ module.exports = {
co(function* () {
return yield thunkQuery(UnitOfAnalysisTagLink.delete().where(UnitOfAnalysisTagLink.id.equals(req.params.id)));
}).then(function () {
bologger.log({
user: req.user.id,
action: 'delete',
object: 'UnitOfAnalysisTagLink',
entity: req.params.id,
info: 'Delete uoa tag link'
});
res.status(204).end();
}, function (err) {
next(err);
Expand Down
23 changes: 23 additions & 0 deletions backend/app/controllers/uoatags.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var client = require('app/db_bootstrap'),
_ = require('underscore'),
config = require('config'),
BoLogger = require('app/bologger'),
bologger = new BoLogger(),
UnitOfAnalysisTag = require('app/models/uoatags'),
AccessMatrix = require('app/models/access_matrices'),
Translation = require('app/models/translations'),
Expand Down Expand Up @@ -58,6 +60,13 @@ module.exports = {
co(function* () {
return yield thunkQuery(UnitOfAnalysisTag.insert(req.body).returning(UnitOfAnalysisTag.id));
}).then(function (data) {
bologger.log({
user: req.user.id,
action: 'insert',
object: 'UnitOfAnalysisTag',
entity: _.first(data).id,
info: 'Add new uoa tag'
});
res.status(201).json(_.first(data));
}, function (err) {
next(err);
Expand All @@ -68,6 +77,13 @@ module.exports = {
co(function* () {
return yield thunkQuery(UnitOfAnalysisTag.update(req.body).where(UnitOfAnalysisTag.id.equals(req.params.id)));
}).then(function () {
bologger.log({
user: req.user.id,
action: 'update',
object: 'UnitOfAnalysisTag',
entity: req.params.id,
info: 'Update uoa tag'
});
res.status(202).end();
}, function (err) {
next(err);
Expand All @@ -78,6 +94,13 @@ module.exports = {
co(function* () {
return yield thunkQuery(UnitOfAnalysisTag.delete().where(UnitOfAnalysisTag.id.equals(req.params.id)));
}).then(function () {
bologger.log({
user: req.user.id,
action: 'delete',
object: 'UnitOfAnalysisTag',
entity: req.params.id,
info: 'Delete uoa tag'
});
res.status(204).end();
}, function (err) {
next(err);
Expand Down
23 changes: 23 additions & 0 deletions backend/app/controllers/uoatypes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var client = require('app/db_bootstrap'),
_ = require('underscore'),
config = require('config'),
BoLogger = require('app/bologger'),
bologger = new BoLogger(),
UnitOfAnalysisType = require('app/models/uoatypes'),
AccessMatrix = require('app/models/access_matrices'),
Translation = require('app/models/translations'),
Expand Down Expand Up @@ -58,6 +60,13 @@ module.exports = {
co(function* () {
return yield thunkQuery(UnitOfAnalysisType.insert(req.body).returning(UnitOfAnalysisType.id));
}).then(function (data) {
bologger.log({
user: req.user.id,
action: 'insert',
object: 'UnitOfAnalysisType',
entity: _.first(data).id,
info: 'Add new uoa type'
});
res.status(201).json(_.first(data));
}, function (err) {
next(err);
Expand All @@ -68,6 +77,13 @@ module.exports = {
co(function* () {
return yield thunkQuery(UnitOfAnalysisType.update(req.body).where(UnitOfAnalysisType.id.equals(req.params.id)));
}).then(function () {
bologger.log({
user: req.user.id,
action: 'update',
object: 'UnitOfAnalysisType',
entity: req.params.id,
info: 'Update uoa type'
});
res.status(202).end();
}, function (err) {
next(err);
Expand All @@ -78,6 +94,13 @@ module.exports = {
co(function* () {
return yield thunkQuery(UnitOfAnalysisType.delete().where(UnitOfAnalysisType.id.equals(req.params.id)));
}).then(function () {
bologger.log({
user: req.user.id,
action: 'delete',
object: 'UnitOfAnalysisType',
entity: req.params.id,
info: 'Delete uoa type'
});
res.status(204).end();
}, function (err) {
next(err);
Expand Down
1 change: 1 addition & 0 deletions backend/db_dump/patches/20160322-01-essences.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WITH new_values ("tableName","name","fileName","nameField") as (
('UnitOfAnalysisType', 'UnitOfAnalysisType', 'uoatypes', 'name'),
('UnitOfAnalysisClassType', 'UnitOfAnalysisClassType', 'uoaclasstypes', 'name'),
('UnitOfAnalysisTag', 'UnitOfAnalysisTag', 'uoatags', 'name'),
('UnitOfAnalysisTagLink', 'UnitOfAnalysisTagLink', 'uoataglinks', 'id'),
('Projects', 'projects', 'projects', 'codeName'),
('Discussions', 'Discussions', 'discussions', 'name'),
('Users', 'Users', 'users', 'email'),
Expand Down

0 comments on commit 0c7bec6

Please sign in to comment.