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

Styling code for readability #55

Open
matthewdking opened this issue May 14, 2018 · 0 comments
Open

Styling code for readability #55

matthewdking opened this issue May 14, 2018 · 0 comments

Comments

@matthewdking
Copy link
Contributor

Just a tiny point that in general sql commands are quite long and can be complex to understand. Having them on one line makes them almost impossible to read due to scrolling etc

// post scale comments for symptom scale
const postSymptomScale = (symptom, username, comment_1, comment_2, comment_3, comment_4, comment_5, comment_6, comment_7, comment_8, comment_9, comment_10) => dbConnect.query('insert into symptom_scale (symptom_id, user_id, comment_1, comment_2, comment_3, comment_4, comment_5, comment_6, comment_7, comment_8, comment_9, comment_10) values ((select id from symptoms where symptom = $1 and user_id=(select id from users where username=$2)), (select id from users where username = $2), $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)', [symptom, username, comment_1, comment_2, comment_3, comment_4, comment_5, comment_6, comment_7, comment_8, comment_9, comment_10]);
// post scale comment for factor scale
const postFactorScale = (factor, username, comment_1, comment_2, comment_3, comment_4, comment_5, comment_6, comment_7, comment_8, comment_9, comment_10) => dbConnect.query('insert into factor_scale (factor_id, user_id, comment_1, comment_2, comment_3, comment_4, comment_5, comment_6, comment_7, comment_8, comment_9, comment_10) values ((select id from factors where factor = $1 and user_id=(select id from users where username=$2)), (select id from users where username = $2), $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)', [factor, username, comment_1, comment_2, comment_3, comment_4, comment_5, comment_6, comment_7, comment_8, comment_9, comment_10]);

I would advise making this more readable splitting the query over several lines. In general I believe it is not advisable to have a line length of over 80 characters.

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

No branches or pull requests

1 participant