Skip to content

code review session1#1

Open
iSakha wants to merge 74 commits intomasterfrom
dev
Open

code review session1#1
iSakha wants to merge 74 commits intomasterfrom
dev

Conversation

@iSakha
Copy link
Copy Markdown
Owner

@iSakha iSakha commented Jul 17, 2022

No description provided.


const [row] = await auth.validateUser(req.body.login);

const dbUser = row[0]; // !!!!!
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to assign dbUser already, like const dbUser = await auth.validateUser(req.body.login)?.row[0]


const dbUser = row[0]; // !!!!!

console.log("row:", row);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and in all pull request - remove console.log. They are needed only in development


if (row.length > 0) {
let passwordEnteredByUser = req.body.pass;
let salt = row[0].salt;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and in all pull request - use const if variable will not be changed. If it's object - remember that properties could be changed in const

if (bcrypt.hashSync(passwordEnteredByUser, salt) === row[0].crypto) {
if (bcrypt.hashSync(passwordEnteredByUser, salt) === dbUser.crypto) {

let user = {};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const user = {}, const name = {} etc

let idFixture = [];

for (let i = 1; i < req.body.length; i++) {
idFixture.push(req.body[i].idFixture);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see if you can use map, const idFixture = req.body.map(item => item.idFixture)

let idF_1 = idFixture[0];
let idF_2 = idFixture[1];
let idF_3 = idFixture[2];
let idF_4 = idFixture[3];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks better if it's const [idF_1, idF_2, idF_3, idF_4] = idFixture;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это временные вспомогательные переменные,я их уберу вообще нафиг)

let query_4 = "";

for (let i = 0; i < idFixture.length; i++) {
query_2 += " WHEN idFixture = '" + idFixture[i] + "' THEN " + idW;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try string literals, WHEN idFixture = '${dFixture[I]}' THEN ${idW}
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals


let query_3 = " END WHERE idFixture IN ("

let q = query_1 + query_2 + query_3 + query_4 + ")";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, string literal style is better

}
}

// static fixturesMovement() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unused comments


if (status.status === 200) {

// fixtureRow.push(req.body.idFixture);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants