-
Notifications
You must be signed in to change notification settings - Fork 34
Conversation
Looks cool. Let's have a video call with @sylwiabr to see how it works and to chat about missing things. Great job with that! |
dd2254b
to
66d4094
Compare
We are waiting for this to be finished. |
090dd8c
to
ca98458
Compare
loadScript('https://cdnjs.cloudflare.com/ajax/libs/sql-formatter/4.0.2/sql-formatter.min.js') | ||
|
||
class SqlVisualization extends Visualization { | ||
static inputType = 'Any' // 'Standard.Database.Data.Table.Table | Standard.Database.Data.Column.Column' // TODO change this once sum types are properly supported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Too long line, max 100 chars everywhere - apply to ALL files
- In comments always add links to issues describing them.
- Comments should be valid english sentences. missing dot
Apply to all your code.
this.setPreprocessorModule('Standard.Visualization.Sql.Visualization') | ||
this.setPreprocessorCode(`x -> here.prepare_visualization x`) | ||
|
||
// mock theme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments should be valid sentences. Also, they should be understandable by people not familiar with codebase, thisdefinitely is not. It needs to describe why it is a mock and what issue it is waiting for with a link to the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mock theme will be removed anyway before the PR is merged, as we discussed that this PR should be merged after #1337
src/rust/ide/view/graph-editor/src/builtin/visualization/java_script/sql.js
Outdated
Show resolved
Hide resolved
function splitTypeName(name) { | ||
var ix = name.lastIndexOf('.') | ||
if (ix < 0) { | ||
return ['', name] | ||
} | ||
|
||
return [name.substr(0, ix + 1), name.substr(ix + 1)] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all these functions should have comments describing their behavior. Or better naming. If I see name splitTypeName
I do not understand what does it do - split from what, into what? Better naming is preferred. IF its not possible, musch better and detailed docs. Thesame applies to other functions, like a super-long function rendeParameter
. Its namedoesnt tell anything about what it does, and is looks complex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments and changed names a bit.
|
||
const actualTypeColor = theme.getColorForType(actualType) | ||
const fgColor = actualTypeColor | ||
let bgColor = [...fgColor.slice(0, 3), bgAlpha] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magic numbers. Do not use literals like that. Extract them to well named variables. You can use 0
as it means start, but 3
is magical
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I changed this to const baseChannels = 3
since that 3
represents the RGB
channels that are kept when changing opacity; it's also now a separate function so it is easier to see what it does.
I assume that I can use 2
without treating it like a magic number when I'm dividing things by two, right? (Like I want to compute the middle of something, so I have width / 2
)
src/rust/ide/view/graph-editor/src/builtin/visualization/java_script/sql.js
Outdated
Show resolved
Hide resolved
src/rust/ide/view/graph-editor/src/builtin/visualization/java_script/sql.js
Outdated
Show resolved
Hide resolved
I'm not sure regarding the code quality - the functions are super long, lack of docs in many places, long expressions are not split into variables etc. I would like @farmaazon to review it from a perspective of someone that does not know what this code does and leave comments - this code should be understandable to every reader easily, without browisng connected code - the logic should be easy to follow. I feel it is not. Ada, would you mind looking at it please? |
I think I could refactor it a bit to make the functions a bit smaller and add docs before a re-review? |
13c2f7b
to
9849cd7
Compare
05b2eb2
to
117ba73
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is MUCH nicer. I was able to create a proper review of it now! Few inor things, Im accepting it. After fixing them, feel free to merge it <3
src/rust/ide/view/graph-editor/src/builtin/visualization/java_script/sql.js
Show resolved
Hide resolved
src/rust/ide/view/graph-editor/src/builtin/visualization/java_script/sql.js
Show resolved
Hide resolved
src/rust/ide/view/graph-editor/src/builtin/visualization/java_script/sql.js
Outdated
Show resolved
Hide resolved
const formatted = sqlFormatter.format(parsedData.code, { | ||
params: params, | ||
language: language, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line would probably fail if parsedData is for example undefined
, null
, or a number. We should make our visualizations as error prone as possible, so please, make more checks regarding the input data!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, parsedData
is what is returned by the visualization preprocessor which is controlled by the visualization itself, so I think we have control over what parsedData
should look like.
src/rust/ide/view/graph-editor/src/builtin/visualization/java_script/sql.js
Outdated
Show resolved
Hide resolved
src/rust/ide/view/graph-editor/src/builtin/visualization/java_script/sql.js
Outdated
Show resolved
Hide resolved
src/rust/ide/view/graph-editor/src/builtin/visualization/java_script/sql.js
Outdated
Show resolved
Hide resolved
src/rust/ide/view/graph-editor/src/builtin/visualization/java_script/sql.js
Outdated
Show resolved
Hide resolved
src/rust/ide/view/graph-editor/src/builtin/visualization/java_script/sql.js
Show resolved
Hide resolved
which was committed by mistake
(rounded corners, highlighted index)
f159037
to
69178f7
Compare
Original commit: enso-org/ide@132ae3e
Pull Request Description
Implements visualizations for the Database library:
Important Notes
Checklist
Please include the following checklist in your PR:
CHANGELOG.md
was updated with the changes introduced in this PR.