Skip to content

Fix for issue #3217 regarding template search feature#3218

Merged
briri merged 1 commit intodevelopmentfrom
template_search_issue_3217
Oct 24, 2022
Merged

Fix for issue #3217 regarding template search feature#3218
briri merged 1 commit intodevelopmentfrom
template_search_issue_3217

Conversation

@gjacob24
Copy link
Contributor

@gjacob24 gjacob24 commented Oct 3, 2022

Fixes #3217

Changes proposed in this PR:

  • code changes in scope method for search in file app/models/template.rb

@gjacob24 gjacob24 requested review from briri and johnpinto1 October 3, 2022 14:20
@gjacob24 gjacob24 force-pushed the template_search_issue_3217 branch from 3db6366 to f0f03c0 Compare October 3, 2022 15:01
@gjacob24
Copy link
Contributor Author

gjacob24 commented Oct 3, 2022

@briri with John's help I made some changes to the format of the code so that it passes the Rubocop checks. However, the MySQL and PostgreSQL tests are still failing and I am not sure if it's related to the code change and if yes, how to fix it..
When you have some time, please let me know what I should do next to sort this. Thanks!

Copy link
Contributor

@briri briri left a comment

Choose a reason for hiding this comment

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

Not sure if that closing ) is in the right spot. See my comment.

The tests are failing due to an issue with Capybara which will be unrelated to your changes. My guess is that an update to the gem over the past few months broke it. We will need to do some investigation into it over the next few weeks.

'lower(orgs.name) LIKE lower(:term)',
term: "%#{term}%")
unarchived
.joins(<<~SQL)
Copy link
Contributor

@briri briri Oct 3, 2022

Choose a reason for hiding this comment

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

doesn't that ) belong at the end of the SQL Heredoc? Like this:

.joins(<<~SQL
  JOIN orgs AS search_term_orgs ON search_term_orgs.id = templates.org_id
SQL)

If rubocop isn't happy with it, maybe set the SQL to a variable and then do .joins(my_var)

Copy link
Contributor Author

@gjacob24 gjacob24 Oct 3, 2022

Choose a reason for hiding this comment

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

Oh interesting... I copied the format from examples on line number 137 and 150 in the same file. I tried making the change you suggested (i.e. moving the ) )locally and it seems to mess up the formatting (for the entire file) 🤔

I'm hoping that since the current format has been used in the past, has now passed rubocop checks and works..then maybe it can stay the same? Let me know what you think.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh weird ok. If it works then I'm happy.

Typically with heredoc, anything after the <<~SQL ... SQL becomes part of the text. Maybe the ) is required to close out the prior part of the SQL statement that ActiveRecord is generating behind the scenes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It definitely works, but John just mentioned that he would prefer the second suggestion you made which is to store the SQL part in a var and do .joins(var),as that it more clear. So I might make those changes and push it again. Will keep you posted.

We should then change the format of the other two scopes as well I'm guessing, so that they are all of the same format (?)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, if it works. If not leave it as is

'lower(orgs.name) LIKE lower(:term)',
term: "%#{term}%")
unarchived
.joins(<<~SQL)
Copy link
Contributor

Choose a reason for hiding this comment

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

oh weird ok. If it works then I'm happy.

Typically with heredoc, anything after the <<~SQL ... SQL becomes part of the text. Maybe the ) is required to close out the prior part of the SQL statement that ActiveRecord is generating behind the scenes.

@briri briri merged commit 87abe8c into development Oct 24, 2022
@briri briri deleted the template_search_issue_3217 branch October 24, 2022 15:17
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