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

Bug: in project search implementation trigger function to generate tsvector is running twice #4817

Open
Waishnav opened this issue Mar 13, 2024 · 4 comments · May be fixed by #4851
Open

Bug: in project search implementation trigger function to generate tsvector is running twice #4817

Waishnav opened this issue Mar 13, 2024 · 4 comments · May be fixed by #4851
Labels

Comments

@Waishnav
Copy link
Contributor

Is your feature request related to a problem? Please describe

I was just reviewing some of the old commits of Project Search implementation, I found out that the trigger function is both define in the migration file as well as in the model file of project, at first I thought it was needed but I tested removing the trigger function lines from the model/project.rb file. The trigger function of generating tsvector of name and description and storing it in searchable column was still working.

Describe the solution you'd like

By removing the unnecessary lines, from model/project.rb we could able to refactor this code.

# model/project.rb
  trigger.before(:insert, :update) do
    "tsvector_update_trigger(
        searchable, 'pg_catalog.english', description, name
      );"
  end

Describe alternatives you've considered

No response

Additional context

No response

Are you working on this?

Yes

@tanmoysrt
Copy link
Member

I don't have idea if that was intentionally.
@tachyons can you please revew this issue ?

@Waishnav
Copy link
Contributor Author

Waishnav commented Mar 19, 2024

@tachyons You can checkout this video where I demonstrate and test whether this lines are redundant or not.

cv.search.refactor.mp4

@Waishnav
Copy link
Contributor Author

this video shows that actually we were generating the tsvector of combinination title and description twice, which is unnecessary computation at database end

@Waishnav Waishnav changed the title Refactoring in project search implementation Bug: Refactoring in project search implementation Mar 21, 2024
@Waishnav Waishnav changed the title Bug: Refactoring in project search implementation Bug: in project search implementation trigger function to generate tsvector is running twice Mar 21, 2024
@Waishnav
Copy link
Contributor Author

@tachyons could you please review this video

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants