Skip to content

Commit 62a1f45

Browse files
committed
lint fixes
1 parent 8b5820f commit 62a1f45

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

scripts/process-remaining-ubahn-uuids.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ const request = require('superagent')
77
const config = require('config')
88

99
/**
10-
*
10+
*
1111
* @param {string} handle - The member handle
12-
* @returns {Promise<object>} The member details from the member API
12+
* @returns {Promise<object>} The member details from the member API
1313
*/
14-
async function getMemberDetailsByHandle(handle) {
14+
async function getMemberDetailsByHandle (handle) {
1515
const token = await helper.getM2MToken()
1616
let res
1717
try {
@@ -45,24 +45,23 @@ const processRemainingUUIDs = async (tableName, columnNames) => {
4545
console.log()
4646

4747
for (const columnName of _.split(columnNames, ',')) {
48-
49-
let transaction = await models.sequelize.transaction()
48+
const transaction = await models.sequelize.transaction()
5049

5150
try {
5251
// check each column to find distinct existing uuids which have not yet been converted to TC legacy user id
5352
const query = `SELECT DISTINCT ${columnName} FROM bookings.${tableName} WHERE LENGTH(${columnName}) > 9 AND ${columnName} <> '00000000-0000-0000-0000-000000000000';`
5453
console.log(`Executing query in table ${tableName} against column ${columnName}`)
5554
console.log(`SQL query: ${query}`)
5655
let results = await models.sequelize.query(query, { type: Sequelize.QueryTypes.SELECT })
57-
56+
5857
if (results.length > 0) {
5958
results = _.uniq(_.map(_.filter(results, val => toString(val[`${columnName}`]).length > 9), val => val[`${columnName}`]))
6059
console.log(`SQL query result: ${JSON.stringify(results)}`)
61-
60+
6261
// get the ubahn uuid to handle map
6362
const ubahnConn = await tcUserId.getUbahnDatabaseConnection(dbUrl)
6463
const uuidToHandleMap = await tcUserId.getUserUbahnUUIDToHandleMap(ubahnConn, results)
65-
64+
6665
// get the handle to legacy topcoder id map
6766
for (const handle of Object.values(uuidToHandleMap)) {
6867
console.log(`handle to search for ${handle}`)
@@ -71,20 +70,20 @@ const processRemainingUUIDs = async (tableName, columnNames) => {
7170
handleToIDMap[member.handleLower] = member.userId
7271
}
7372
}
74-
73+
7574
// build the update queries
7675
let sql = ''
7776
for (const [key, value] of Object.entries(uuidToHandleMap)) {
7877
if (!_.isUndefined(handleToIDMap[value.toLowerCase()])) {
7978
sql += `UPDATE bookings.${tableName} SET ${columnName} = '${handleToIDMap[value.toLowerCase()]}' WHERE ${columnName} = '${key}';`
8079
}
8180
}
82-
81+
8382
// execute update queries if and only if it's not in test mode
8483
if (sql !== '') {
8584
console.log(`SQL UPDATE statements: ${sql}`)
8685
if (MODE !== 'test') {
87-
console.log(`Executing UPDATE statements`)
86+
console.log('Executing UPDATE statements')
8887
await models.sequelize.query(sql, { type: Sequelize.QueryTypes.UPDATE, transaction: transaction })
8988
}
9089
} else {
@@ -93,15 +92,14 @@ const processRemainingUUIDs = async (tableName, columnNames) => {
9392
} else {
9493
console.log(`No data eligible to be updated for table: ${tableName} against column ${columnName}`)
9594
}
96-
95+
9796
// only for readability
9897
console.log('---------------------------------------------------------------------------------------------------------------')
9998
console.log()
10099

101100
await transaction.commit()
102-
103101
} catch (error) {
104-
console.log(`Error encountered`)
102+
console.log('Error encountered')
105103
console.error(JSON.stringify(error))
106104
await transaction.rollback()
107105
}
@@ -119,7 +117,7 @@ processRemainingUUIDs(tableName, columnNames).then(res => {
119117
console.log(`Processed remaining records for model '${tableName}' against columns: ${columnNames}`)
120118
process.exit(0)
121119
}).catch(err => {
122-
console.log(`Error encountered!`)
120+
console.log('Error encountered!')
123121
console.error(`${JSON.stringify(err)}`)
124122
process.exit(1)
125-
})
123+
})

0 commit comments

Comments
 (0)