-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upgrade to newest API client version (#449)
* chore: update algolia version * WIP: fix tests until FowardToReplicas * chore: fix SubReplicas tests * chore: fix Book tests * chore: fix pagination tests * chore: fix disabled indexing tests * fix tests * ensure latest gem version * fix: virtual replica test * test matrix * Update Gemfile * Update config.yml * Update Gemfile * Update config.yml * Update config.yml * Update algoliasearch-rails.rb * sanitizer * Update algoliasearch-rails.rb * Update algoliasearch-rails.rb * Update algoliasearch-rails.rb * Update pagy.rb * Update integration_spec.rb * Update pagy.rb * Update integration_spec.rb * Update pagy.rb * Update pagy.rb * Update integration_spec.rb * Update integration_spec.rb * sanitizer * chore: clean up algoliasearch/configuration * remove `index` method * chore: handle todos * Update algoliasearch-rails.gemspec * Update spec_helper.rb * address feedback * feat: allow setting user agent * pin version * Update algoliasearch-rails.gemspec * Update config.yml * prep release * feat: issue sync
- Loading branch information
1 parent
9c1a0a4
commit 5788eda
Showing
12 changed files
with
439 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: 'Issue sync with Jira' | ||
on: | ||
issues: | ||
types: [opened] | ||
|
||
permissions: | ||
issues: write | ||
contents: read | ||
|
||
jobs: | ||
sync: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Create ticket | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const action = context.payload.action; | ||
if (action !== 'opened') { | ||
return; | ||
} | ||
const title = context.payload.issue.title; | ||
const body = context.payload.issue.body; | ||
const res = await fetch('https://algolia.atlassian.net/rest/api/2/issue', { | ||
method: 'POST', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json', | ||
'Authorization': `Basic ${{ secrets.JIRA_TOKEN }}` | ||
}, | ||
body: JSON.stringify({ | ||
fields: { | ||
description: `Issue created by ${context.actor} at ${context.payload.issue.html_url} \n\n${body}`, | ||
issuetype: { | ||
id: '10001' | ||
}, | ||
parent: { | ||
key: 'DI-1911' | ||
}, | ||
project: { | ||
id: '10118' | ||
}, | ||
summary: `[GH-ISSUE] ${title}` | ||
}, | ||
update: {} | ||
}) | ||
}); | ||
if (!res.ok) { | ||
throw new Error(`Failed to create ticket: ${res.statusText} (${res.status}) - ${await res.text()}`); | ||
} | ||
const data = await res.json(); | ||
console.log(`Created ticket: ${data.key}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
Version 3 of the `algoliasearch-rails` gem replaces the Algolia API client version in use from version 2 to version 3. | ||
These versions of the API client differ significantly, so you likely need to make code changes when updating. | ||
We've tried keeping most of the changes internal, but there are still some breaking changes you need to be aware of when upgrading. | ||
|
||
If you encounter any breaking changes to the Rail integration that are not listed here, please open a Pull Request to add them to this list. | ||
|
||
## Breaking changes | ||
|
||
`algolia_ensure_init` (this method is protected and shouldn't be called manually, but we list it here anyways): the method no longer returns an initialized `index` object as this is not part of the new API client. The method now returns nothing, but it still ensures the index exists and applies settings if needed. | ||
|
||
--- | ||
`Model.search`, `Model.raw_search`: response keys in the new API client are no longer strings, but are *always* symbols. For example: | ||
```ruby | ||
# Before | ||
results = Product.raw_search('shirt') | ||
p results['hits'] | ||
|
||
# After | ||
results = Product.raw_search('shirt') | ||
p results[:hits] | ||
``` | ||
--- | ||
`Model.search_for_facet_values`: this no longer returns an array of hashes, but an array of objects of type `Algolia::Search::FacetHits`: | ||
```ruby | ||
# Before | ||
facets = Color.search_for_facet_values('short_name', 'bl', :query => 'black') | ||
puts facets.first['value'] | ||
|
||
# After | ||
facets = Color.search_for_facet_values('short_name', 'bl', :query => 'black') | ||
facets.first.value | ||
``` | ||
|
||
--- | ||
`Model.index_name` takes an additional, optional parameter. You can use this if you want to get the name of one of your replica indices, which ensures the index naming takes configuration that modifies the index name into account. | ||
For example, if you have the `:per_environment` option set to true, it will automatically add the environment name in the index name. | ||
```ruby | ||
def Product | ||
include AlgoliaSearch | ||
|
||
algoliasearch({ per_environment: true }) do | ||
add_replica 'Suits', per_environment: true do | ||
# replica settings | ||
end | ||
end | ||
|
||
end | ||
main_index_name = Product.index_name | ||
replica_index_name = Product.index_name('Suits') | ||
``` | ||
|
||
--- | ||
`AlgoliaSearch::Configuration.client_opts`, `AlgoliaSearch::Configuration::REQUIRED_CONFIGURATION` and `AlgoliaSearch::SafeIndex` have been removed. | ||
If you need to configure the API client other than the ways that are provided now, it's recommended to set up an instance manually. | ||
|
||
--- | ||
`Model.index` and `Model.algolia_index` have been removed, as there is no notion of an `Index` object in the new version of the API clients. | ||
Instead, you can use `Model.index_name` to get the name of the index to target, and use this on an instance of the API client directly. | ||
|
||
```ruby | ||
# Before | ||
res = Product.index.search('shoe') | ||
|
||
# After | ||
res = AlgoliaSearch.client.search_single_index(Product.index_name, { query: 'shoe' }) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.