Skip to content

Remove unmaintained ember-algolia and ember-browserify #611

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

Merged
merged 1 commit into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions app/services/algolia.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import Service from '@ember/service';
import algoliasearch from 'algoliasearch';
import config from 'ember-api-docs/config/environment';
import { denodeify } from 'rsvp';

export default Service.extend({
_search(query, params, callback) {
if (!callback) {
callback = params;
params = undefined;
}
if (query) {
if (Array.isArray(query) && !params) { // if multiple indices
this._client.search(query, callback);
} else if (!params) { // if no params
this.accessIndex(query.indexName).search(query.query, callback);
} else { // if params and callback
this.accessIndex(query.indexName).search(query.query, params, callback);
}
} else {
callback(new Error(`Could not search algolia for query "${query}"`));
}
},

accessIndex(IndexName) {
if (!this._indices[IndexName]) {
this._indices[IndexName] = this._client.initIndex(IndexName);
}
return this._indices[IndexName];
},

init() {
this._super(...arguments);
this._client = algoliasearch(config.algolia.algoliaId, config.algolia.algoliaKey);
this._indices = {};
this.search = denodeify(this._search.bind(this));
}
});
12 changes: 3 additions & 9 deletions app/services/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import { get, set } from '@ember/object';
import { A as emberArray } from '@ember/array';
import { alias } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import { denodeify } from 'rsvp';

export default Service.extend({

_searchClient: service('algolia'),
_algoliaService: service('algolia'),
_projectService: service('project'),
_projectVersion: alias('_projectService.version'),

Expand All @@ -34,14 +32,10 @@ export default Service.extend({
};

return set(this, 'results', (yield this.doSearch(searchObj, params)));

}).restartable(),

doSearch(searchObj, params) {
const client = this._searchClient;
const searchFn = denodeify(client.search.bind(client));
return searchFn(searchObj, params).then((results) => {
return get(results, 'hits');
});
return this._algoliaService.search(searchObj, params)
.then(results => get(results, 'hits'));
}
});
2 changes: 1 addition & 1 deletion config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = function(environment) {
/^[\w-]+\.emberjs\.com$/
]
},
'ember-algolia': {
algolia: {
algoliaId: ALGOLIA_APP_ID,
algoliaKey: ALGOLIA_API_KEY
},
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"test": "node run-tests.js"
},
"dependencies": {
"algoliasearch": "^3.31.0",
"bourbon": "5.1.0",
"ember-cli-browserstack": "^0.0.6",
"ember-rfc176-data": "^0.3.5",
Expand All @@ -37,16 +36,15 @@
"testem": "^2.14.0"
},
"devDependencies": {
"algoliasearch": "^3.32.1",
"@ember/jquery": "^0.5.2",
"@ember/optional-features": "^0.6.3",
"broccoli-asset-rev": "^3.0.0",
"broccoli-funnel": "^2.0.1",
"broccoli-merge-trees": "^2.0.0",
"ember-a11y-testing": "^0.5.4",
"ember-algolia": "0.0.10",
"ember-anchor": "~0.2.0",
"ember-auto-import": "^1.2.21",
"ember-browserify": "^1.2.2",
"ember-cli": "~3.4.4",
"ember-cli-app-version": "^3.2.0",
"ember-cli-autoprefixer": "^0.7.0",
Expand Down
Loading