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

Skip full text search if failed #9654

Merged
merged 2 commits into from
Dec 30, 2018
Merged

Skip full text search if failed #9654

merged 2 commits into from
Dec 30, 2018

Conversation

tribela
Copy link
Contributor

@tribela tribela commented Dec 29, 2018

Sometimes, ES server are dead while main server is live.
We should give general search results(accounts, hashtags) even if ES server is dead.

results[:hashtags] = perform_hashtags_search! if hashtag_searchable?
begin
results[:statuses] = perform_statuses_search! if full_text_searchable?
rescue Faraday::ConnectionFailed
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be more elegant to just add a rescue block to the perform_statuses_search! method

@@ -62,7 +62,12 @@ def url_resource_symbol

def full_text_searchable?
Copy link
Member

Choose a reason for hiding this comment

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

That's not the right method. Also, def/end blocks can have a rescue clause without extra begin/end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

like this?

def method
  do_something
rescue Exception
  fallback
end

Copy link
Member

Choose a reason for hiding this comment

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

Yes, like that. 👍

@Gargron Gargron merged commit 511231c into mastodon:master Dec 30, 2018
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
* Skip full text search if failed

* Move rescue block to "perform_statuses_search!"
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