Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: apply Prettier formatting to the codebase #3182

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions backend/data/csvInserter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs');
const Papa = require('papaparse');
const path = require('path');
const fs = require("fs");
const Papa = require("papaparse");
const path = require("path");

// expected args:
// - csv filename
Expand All @@ -11,30 +11,30 @@ const csvFilename = args[0];
const tableName = args[1];
const outfilePath = args[2];

fs.readFile( path.join(__dirname, csvFilename), function (err, fileContents) {
fs.readFile(path.join(__dirname, csvFilename), function (err, fileContents) {
if (err) {
throw err;
}

let output = '';
let output = "";

const data = Papa.parse(fileContents.toString(), { header: true }).data;

const columns = Object.keys(data[0]).join(',');
const columns = Object.keys(data[0]).join(",");

data.forEach((row) => {
const values = Object.values(row).map(columnValue => {
const values = Object.values(row).map((columnValue) => {
columnValue = columnValue.replace(/'/g, "''");
if (columnValue === '') {
return 'null';
if (columnValue === "") {
return "null";
}
return `'${columnValue}'`;
});

output += `INSERT INTO ${tableName} (${columns}) values (${values.join(',')});\n`
output += `INSERT INTO ${tableName} (${columns}) values (${values.join(",")});\n`;
});

fs.writeFile(outfilePath, output, (err) => {
if (err) throw err;
})
});
});
2 changes: 1 addition & 1 deletion backend/data/csvUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fs.readFile(path.join(__dirname, csvFilenameOld), function (err, fileContentsOld
});

output += `INSERT INTO ${tableName} (${columnsNew.join(",")}) values (${values.join(
","
",",
)});\n`;
}
});
Expand Down
2 changes: 1 addition & 1 deletion backend/database.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@
"database": "d4adprod"
}
}
}
}
42 changes: 20 additions & 22 deletions backend/migrations/20200605145412-programs.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,51 @@
'use strict';
"use strict";

var dbm;
var type;
var seed;
var fs = require('fs');
var path = require('path');
var fs = require("fs");
var path = require("path");
var Promise;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
Promise = options.Promise;
};

exports.up = function(db) {
var filePath = path.join(__dirname, 'sqls', '20200605145412-programs-up.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
exports.up = function (db) {
var filePath = path.join(__dirname, "sqls", "20200605145412-programs-up.sql");
return new Promise(function (resolve, reject) {
fs.readFile(filePath, { encoding: "utf-8" }, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);
console.log("received data: " + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports.down = function(db) {
var filePath = path.join(__dirname, 'sqls', '20200605145412-programs-down.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
exports.down = function (db) {
var filePath = path.join(__dirname, "sqls", "20200605145412-programs-down.sql");
return new Promise(function (resolve, reject) {
fs.readFile(filePath, { encoding: "utf-8" }, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);
console.log("received data: " + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports._meta = {
"version": 1
version: 1,
};
47 changes: 24 additions & 23 deletions backend/migrations/20200616144558-seed-programs.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
'use strict';
"use strict";

var dbm;
var type;
var seed;
var fs = require('fs');
var path = require('path');
var fs = require("fs");
var path = require("path");
var Promise;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
Promise = options.Promise;
};

exports.up = function(db) {
const fileName = process.env.NODE_ENV === 'test' ? '20200616144558-seed-programs-up-TEST.sql' : '20200616144558-seed-programs-up.sql';
var filePath = path.join(__dirname, 'sqls', fileName);
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
exports.up = function (db) {
const fileName =
process.env.NODE_ENV === "test"
? "20200616144558-seed-programs-up-TEST.sql"
: "20200616144558-seed-programs-up.sql";
var filePath = path.join(__dirname, "sqls", fileName);
return new Promise(function (resolve, reject) {
fs.readFile(filePath, { encoding: "utf-8" }, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);
console.log("received data: " + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports.down = function(db) {
var filePath = path.join(__dirname, 'sqls', '20200616144558-seed-programs-down.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
exports.down = function (db) {
var filePath = path.join(__dirname, "sqls", "20200616144558-seed-programs-down.sql");
return new Promise(function (resolve, reject) {
fs.readFile(filePath, { encoding: "utf-8" }, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);
console.log("received data: " + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports._meta = {
"version": 1
version: 1,
};
42 changes: 20 additions & 22 deletions backend/migrations/20200629153418-outcomes-table.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,51 @@
'use strict';
"use strict";

var dbm;
var type;
var seed;
var fs = require('fs');
var path = require('path');
var fs = require("fs");
var path = require("path");
var Promise;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
Promise = options.Promise;
};

exports.up = function(db) {
var filePath = path.join(__dirname, 'sqls', '20200629153418-outcomes-table-up.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
exports.up = function (db) {
var filePath = path.join(__dirname, "sqls", "20200629153418-outcomes-table-up.sql");
return new Promise(function (resolve, reject) {
fs.readFile(filePath, { encoding: "utf-8" }, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);
console.log("received data: " + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports.down = function(db) {
var filePath = path.join(__dirname, 'sqls', '20200629153418-outcomes-table-down.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
exports.down = function (db) {
var filePath = path.join(__dirname, "sqls", "20200629153418-outcomes-table-down.sql");
return new Promise(function (resolve, reject) {
fs.readFile(filePath, { encoding: "utf-8" }, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);
console.log("received data: " + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports._meta = {
"version": 1
version: 1,
};
47 changes: 24 additions & 23 deletions backend/migrations/20200629153929-seed-outcomes.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
'use strict';
"use strict";

var dbm;
var type;
var seed;
var fs = require('fs');
var path = require('path');
var fs = require("fs");
var path = require("path");
var Promise;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
Promise = options.Promise;
};

exports.up = function(db) {
const fileName = process.env.NODE_ENV === 'test' ? '20200629153929-seed-outcomes-up-TEST.sql' : '20200629153929-seed-outcomes-up.sql';
var filePath = path.join(__dirname, 'sqls', fileName);
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
exports.up = function (db) {
const fileName =
process.env.NODE_ENV === "test"
? "20200629153929-seed-outcomes-up-TEST.sql"
: "20200629153929-seed-outcomes-up.sql";
var filePath = path.join(__dirname, "sqls", fileName);
return new Promise(function (resolve, reject) {
fs.readFile(filePath, { encoding: "utf-8" }, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);
console.log("received data: " + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports.down = function(db) {
var filePath = path.join(__dirname, 'sqls', '20200629153929-seed-outcomes-down.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
exports.down = function (db) {
var filePath = path.join(__dirname, "sqls", "20200629153929-seed-outcomes-down.sql");
return new Promise(function (resolve, reject) {
fs.readFile(filePath, { encoding: "utf-8" }, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);
console.log("received data: " + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports._meta = {
"version": 1
version: 1,
};
Loading
Loading