Skip to content

Commit

Permalink
Merge pull request #201 from NickPhura/PRC-1046-2
Browse files Browse the repository at this point in the history
PRC-1046-2: additional minor tweaks to linters/formatting.
  • Loading branch information
NickPhura authored Mar 21, 2019
2 parents ad15fc7 + 839b974 commit 35476d3
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 48 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
node_modules

dist

openshift
sonar-runner
uploads

.vscode
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
node_modules

dist

openshift
sonar-runner
uploads

.vscode
6 changes: 0 additions & 6 deletions api/controllers/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ exports.protectedHead = function(args, res, next) {
};

exports.protectedGet = function(args, res, next) {
var self = this;
self.scopes = args.swagger.operation['x-security-scopes'];

defaultLog.info('args.swagger.params:', args.swagger.operation['x-security-scopes']);

// Build match query if on docId route
Expand Down Expand Up @@ -232,9 +229,6 @@ exports.publicDownload = function(args, res, next) {
};

exports.protectedDownload = function(args, res, next) {
var self = this;
self.scopes = args.swagger.operation['x-security-scopes'];

defaultLog.info('args.swagger.params:', args.swagger.operation['x-security-scopes']);

// Build match query if on docId route
Expand Down
3 changes: 0 additions & 3 deletions api/controllers/feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ exports.publicGet = function(args, res, next) {
});
};
exports.protectedGet = function(args, res, next) {
var self = this;
self.scopes = args.swagger.operation['x-security-scopes'];

defaultLog.info('args.swagger.params:', args.swagger.operation['x-security-scopes']);

var query = {};
Expand Down
3 changes: 0 additions & 3 deletions api/controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ exports.protectedOptions = function(args, res, rest) {
};

exports.protectedGet = function(args, res, next) {
var self = this;
self.scopes = args.swagger.operation['x-security-scopes'];

defaultLog.info('args.swagger.params:', args.swagger.operation['x-security-scopes']);

// Build match query if on userId route
Expand Down
3 changes: 1 addition & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ swaggerTools.initializeMiddleware(swaggerConfig, function(middleware) {
}
// Load up DB
var options = {
poolSize: 10,
user: db_username,
pass: db_password,
reconnectTries: Number.MAX_VALUE, // Never stop trying to reconnect
Expand All @@ -99,7 +98,7 @@ swaggerTools.initializeMiddleware(swaggerConfig, function(middleware) {
};
defaultLog.info('Connecting to:', dbConnection);
mongoose.Promise = global.Promise;
var db = mongoose.connect(encodeURI(dbConnection), options).then(
mongoose.connect(encodeURI(dbConnection), options).then(
() => {
defaultLog.info('Database connected');

Expand Down
5 changes: 5 additions & 0 deletions migrations/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"no-console": "off"
}
}
4 changes: 2 additions & 2 deletions migrations/20181121185425-add-centroid-2dindex.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

var dbm;
var type;
var seed;
var type; // eslint-disable-line no-unused-vars
var seed; // eslint-disable-line no-unused-vars

/**
* We receive the dbmigrate dependency from dbmigrate initially.
Expand Down
4 changes: 2 additions & 2 deletions migrations/20181121194209-add-feature-2dindex.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

var dbm;
var type;
var seed;
var type; // eslint-disable-line no-unused-vars
var seed; // eslint-disable-line no-unused-vars

/**
* We receive the dbmigrate dependency from dbmigrate initially.
Expand Down
4 changes: 2 additions & 2 deletions migrations/20181128220107-add-tantalisID-index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

var dbm;
var type;
var seed;
var type; // eslint-disable-line no-unused-vars
var seed; // eslint-disable-line no-unused-vars

/**
* We receive the dbmigrate dependency from dbmigrate initially.
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"tests": "UPLOAD_DIRECTORY='./api/test/uploads/' jest api --runInBand",
"tests-debug": "node --inspect node_modules/.bin/jest --runInBand",
"coverage": "jest --collectCoverageFrom=api/**.js --coverage api",
"lint": "eslint -c .eslintrc api/**/*.js --ignore-path .eslintignore",
"lint-fix:1": "eslint -c .eslintrc api/**/*.js --ignore-path .eslintignore --fix",
"lint-fix:2": "prettier api/**/*.js --write --loglevel warn",
"lint": "eslint .",
"lint-fix:1": "eslint ./**/*.js --fix",
"lint-fix:2": "prettier ./**/*.js --write --loglevel warn",
"lint-fix": "npm-run-all -l -s -c lint-fix:*"
},
"dependencies": {
Expand Down Expand Up @@ -73,7 +73,7 @@
},
"lint-staged": {
"*.js": [
"eslint -c .eslintrc --ignore-path .eslintignore --fix",
"eslint --fix",
"prettier --write --loglevel warn",
"git add"
]
Expand Down
5 changes: 5 additions & 0 deletions seed/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"no-console": "off"
}
}
1 change: 0 additions & 1 deletion seed/addUsers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
//
// Example: node addUsers.js username password http localhost 3000
//
Expand Down
1 change: 0 additions & 1 deletion seed/loadApps.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
'use strict';

var applist = require('./applist.json');
Expand Down
1 change: 0 additions & 1 deletion seed/loadDocs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
'use strict';

var doclist = require('./doclist.json');
Expand Down
35 changes: 18 additions & 17 deletions seed/seed.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
'use strict';

//
Expand Down Expand Up @@ -75,37 +74,39 @@ var doWork = function(e, route) {
// console.log("e:", e);
var postBody = JSON.stringify(e);

var f;

// Bind the objectID's
if (route === 'api/document' || route === 'api/commentperiod') {
// console.log('app:', _applications);
// console.log('e._application:', e._application);
// console.log('e._decision:', e._decision);
// console.log('e._comment:', e._comment);
if (e._application) {
var f = _.find(_applications, { code: e._application });
f = _.find(_applications, { code: e._application });
e._application = f._id;
} else if (e._decision) {
var f = _.find(_decisions, { code: e._decision });
f = _.find(_decisions, { code: e._decision });
e._decision = f._id;
}

if (route === 'api/document') {
if (e._comment) {
var f = _.find(_comments, { code: e._comment });
f = _.find(_comments, { code: e._comment });
e._comment = f._id;
}
}
}
if (route === 'api/public/comment') {
// console.log('cmt:', _commentPeriods);
var f = _.find(_commentPeriods, { code: e.commentPeriod });
f = _.find(_commentPeriods, { code: e.commentPeriod });
e._commentPeriod = f._id;
}
if (route === 'api/application') {
e.client = e.client;
// e.client = e.client;
}
if (route === 'api/decision') {
var f = _.find(_applications, { code: e._application });
f = _.find(_applications, { code: e._application });
// e._decision = f._id;
e._application = f._id;
}
Expand Down Expand Up @@ -230,7 +231,6 @@ var doWork = function(e, route) {
};

var insertAll = function(route, entries) {
var self = this;
return new Promise(function(resolve, reject) {
console.log('route:', route);

Expand All @@ -246,15 +246,16 @@ var insertAll = function(route, entries) {
});
};

var updateAll = function(collectionName, entries) {
if (_.isEmpty(entries)) {
return Promise.resolve();
}
var updates = _.map(entries, function(entry) {
return update(collectionName, { _id: entry._id }, entry);
});
return Promise.all(updates);
};
// var updateAll = function(collectionName, entries) {
// if (_.isEmpty(entries)) {
// return Promise.resolve();
// }
// var updates = _.map(entries, function(entry) {
// return update(collectionName, { _id: entry._id }, entry);
// });
// return Promise.all(updates);
// };

console.log('Logging in and getting JWT:');
login(username, password)
.then(function() {
Expand Down
18 changes: 14 additions & 4 deletions seed/shapesMigration/updateShapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ var _accessToken = '';
var args = process.argv.slice(2);
console.log('=======================================================');
if (args.length !== 8) {
console.log('Please specify proper parameters: <username> <password> <protocol> <host> <port> <client_id> <grant_type> <auth_endpoint>');
console.log(
'Please specify proper parameters: <username> <password> <protocol> <host> <port> <client_id> <grant_type> <auth_endpoint>'
);
console.log('Example: node updateShapes.js admin admin http localhost 3000 client_id grant_type auth_endpoint');
console.log('=======================================================');
process.exit(1);
Expand Down Expand Up @@ -538,13 +540,21 @@ loginToACRFD(username, password)
})
.then(function(recentlyUpdatedApplicationIDs) {
console.log('-----------------------------------------------');
console.log('5. Fetching all non-deleted ACRFD applications and cross referencing with recently updated Tantalis applications.');
console.log(
'5. Fetching all non-deleted ACRFD applications and cross referencing with recently updated Tantalis applications.'
);
return getAllApplicationIDs().then(function(allACRFDApplicationIDs) {
return allACRFDApplicationIDs.map(app => app.tantalisID).filter(tantalisID => recentlyUpdatedApplicationIDs.includes(tantalisID));
return allACRFDApplicationIDs
.map(app => app.tantalisID)
.filter(tantalisID => recentlyUpdatedApplicationIDs.includes(tantalisID));
});
})
.then(function(applicationIDsToUpdate) {
console.log(` - Found ${applicationIDsToUpdate.length} ACRFD Applications with matching recently updated Tantalis application.`);
console.log(
` - Found ${
applicationIDsToUpdate.length
} ACRFD Applications with matching recently updated Tantalis application.`
);
// For each ACRFD application with a matching recently updated application from Tantalis, fetch the matching record in ACRFD and update it
return applicationIDsToUpdate.reduce(function(previousItem, currentItem) {
return previousItem.then(function() {
Expand Down

0 comments on commit 35476d3

Please sign in to comment.