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

refactor(FIR-33559): Remove obsolete account v1 implementation #103

Merged
merged 5 commits into from
Jun 18, 2024

Conversation

ptiurin
Copy link
Collaborator

@ptiurin ptiurin commented Jun 12, 2024

@ptiurin ptiurin changed the title refactor: Remove obsolete account v1 inplementation refactor: Remove obsolete account v1 implementation Jun 13, 2024
@ptiurin ptiurin changed the title refactor: Remove obsolete account v1 implementation refactor(FIR-33559): Remove obsolete account v1 implementation Jun 13, 2024
@ptiurin ptiurin marked this pull request as ready for review June 13, 2024 08:26
@ptiurin ptiurin requested a review from a team as a code owner June 13, 2024 08:26
Copy link

@alexradzin alexradzin left a comment

Choose a reason for hiding this comment

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

although I have reviewed the changes I do not feel comfortable enough because I am not familiar with the code. Please take a look on my comment. I hope it can help.

`https://some_system_engine.com/${QUERY_URL}`,
(req, res, ctx) => {
const body = (String(req.body) ?? "").toLowerCase();
if (

Choose a reason for hiding this comment

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

I'd re-write this snippet as following:

  if (body.includes("information_schema.engines")) {
    if (body.includes("some_engine")) {
        return res(ctx.json(selectEngineResponse));
    } else if (body.includes("some_other_engine")) {
        return res(ctx.json(selectOtherEngineResponse));
    } else {
        return res(ctx.json(selectEnginesResponse));
    }
  } else {
    return res(ctx.json(selectDbResponse));
  }

IMHO it is much more readable. Also then I'd extract the logic to separate function that returns response according to the body and then use it as following:

return res(ctx.json(getResponse(body)))';

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think nested ifs are much more readable either. However, this test is much simpler - the setup in question was copied over from the previous test. We only need one case in this test so no nesting is necessary. I've removed redundant lines.

accountVersion >= 2
? this.CREATE_PARAMETER_NAMES_V2
: this.CREATE_PARAMETER_NAMES;
const queryParameters: (string | number | boolean)[] = [];

Choose a reason for hiding this comment

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

just not sure why boolean has been added here. I believe that is correct, but it is not clear why it was not in previous implementation and exists here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is probably a mistake. I think that boolean is first used by AUTO_START option, which was added recently. Yet, it's good we updated this annotation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, this was confusing me as well. I think the type checker was only checking one condition here? In any case, this is corrected now.

Copy link
Collaborator

@stepansergeevitch stepansergeevitch left a comment

Choose a reason for hiding this comment

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

LGTM, please look at remaining comments

accountVersion >= 2
? this.CREATE_PARAMETER_NAMES_V2
: this.CREATE_PARAMETER_NAMES;
const queryParameters: (string | number | boolean)[] = [];
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is probably a mistake. I think that boolean is first used by AUTO_START option, which was added recently. Yet, it's good we updated this annotation

Copy link

sonarcloud bot commented Jun 17, 2024

@ptiurin ptiurin merged commit 843f9a0 into main Jun 18, 2024
6 checks passed
@ptiurin ptiurin deleted the refactor-remove-account-v1 branch June 18, 2024 08:33
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.

None yet

3 participants