Skip to content

Review (not for merge) - #19

Open
MaksGovor wants to merge 139 commits into
collaborators-reviewfrom
main
Open

Review (not for merge)#19
MaksGovor wants to merge 139 commits into
collaborators-reviewfrom
main

Conversation

@MaksGovor

Copy link
Copy Markdown
Member

No description provided.

@MaksGovor

Copy link
Copy Markdown
Member Author

@tshemsedinov Good afternoon, can you please do us a code review when you have some free time?

@tshemsedinov tshemsedinov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

Comment thread .eslintignore Outdated
@@ -0,0 +1,3 @@
node_modules/
static/
test/ No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add \n at OEF

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed, thanks

Comment thread app/lib/utils/cachingRequire.js Outdated

const path = require('path');

const cachingRequire = (cacheSize = 10) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

10 is a magic number, use CAMEL_UPPER constant

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed it, thanks a lot

Comment thread app/processing-core.js Outdated
const { exportRes, workerId, error } = message;
finished++;

if (error) reject(error);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe reject and return

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed it, thanks a lot

Comment thread app/transform/graysacle.js Outdated
'use strict';

module.exports = (data) => {
const grayscaleCofs = [0.2126, 0.7152, 0.0722];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Magic numbers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed, thanks.

Comment thread app/transform/graysacle.js Outdated
Comment on lines +6 to +14
for (let i = 0; i < length; i += 4) {
const pictureColors = data.slice(i, i + 3);

const val = pictureColors.reduce(
(acc, color, index) => acc + color * grayscaleCofs[index],
0
);

data[i] = data[i + 1] = data[i + 2] = val;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Magic everywhere

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed, thanks.

Comment thread app/transform/transform1.js Outdated
Comment on lines +4 to +8
for (let i = 0; i < data.length; i += 3) {
data[i] += 40;
data[i + 1] += 40;
data[i + 2] += 40;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Magic

@MaksGovor MaksGovor May 28, 2021

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It was originally planned as functions for a sample project, and in the finished project the user could add his own processing algorithms. But I completely agree with you, even though the example looks terrible, we will definitely fix it

Comment thread server/utils.js Outdated
});
});

const getArgs = (req) =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@tedi4t

tedi4t commented May 30, 2021

Copy link
Copy Markdown
Member

@tshemsedinov, we have fixed everything.

Comment thread .prettierignore Outdated
@@ -0,0 +1,2 @@
README.md
test/ No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add \n at EOF all text files

Comment thread app/lib/worker.js Outdated
Comment thread app/processing-core.js Outdated
};

const killer = () => {
workers.forEach((worker) => worker.kill('SIGTERM'));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for..of loop will be better here

Comment thread app/transform/brightness.js Outdated
for (let i = 0; i < data.length; i++) {
data[i] += ajustment;
}
return data;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you mutate argument, do not need to return it

Comment thread server.js Outdated
Comment thread server/utils.js Outdated
Comment thread server/utils.js
}

async function processImage(req, method) {
const args = await getArgs(req);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Need a try block around getArgs call or around processImage call or upper, errors will pop up, but somewhere you need to catch them.

@tedi4t tedi4t May 30, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Funny-Photoshopped-Thumbs-Image

Comment thread static/client.js Outdated
Comment on lines +9 to +22
fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
})
.then((response) => {
return response.json();
})
.then((data) => {
imageDataToImg(data);
})
.catch(() => {
errorBlockElement.innerHTML = 'Error happened';
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe async/await syntax will be cleaner

MaksGovor and others added 5 commits May 30, 2021 19:33
Co-authored-by: Timur Shemsedinov <timur.shemsedinov@gmail.com>
Co-authored-by: Timur Shemsedinov <timur.shemsedinov@gmail.com>
Co-authored-by: Timur Shemsedinov <timur.shemsedinov@gmail.com>
@MaksGovor

Copy link
Copy Markdown
Member Author

@tshemsedinov, we're all done, thanks a lot

Comment thread app/processing-core.js Outdated
Co-authored-by: Timur Shemsedinov <timur.shemsedinov@gmail.com>
@tedi4t

tedi4t commented May 30, 2021

Copy link
Copy Markdown
Member

@tshemsedinov we've changed it. Thanks for review.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🕵️‍♂️ Code review

3 participants