From df7bd5671a11c49dc907c199d1049e8f5914144f Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Tue, 19 Oct 2021 16:56:22 -0400 Subject: [PATCH 1/7] feat: Refactor to a filterable-store --- addons/api/addon/services/filterable-store.js | 68 +++++++++++++++++++ addons/api/app/services/filterable-store.js | 1 + .../unit/services/filterable-store-test.js | 32 +++++++++ 3 files changed, 101 insertions(+) create mode 100644 addons/api/addon/services/filterable-store.js create mode 100644 addons/api/app/services/filterable-store.js create mode 100644 addons/api/tests/unit/services/filterable-store-test.js diff --git a/addons/api/addon/services/filterable-store.js b/addons/api/addon/services/filterable-store.js new file mode 100644 index 000000000..579e06178 --- /dev/null +++ b/addons/api/addon/services/filterable-store.js @@ -0,0 +1,68 @@ +import Store from '@ember-data/store'; + +class FilterQuery { + _config; + constructor(config) { + this._config = config; + } + + get query() { + const filters = this._buildFilters(this._config); + return this._joinFilters(filters, { inclusive: false }); + } + + /** + * Iterate through filter config to generate array of filter strings + * @param {object} config + */ + _buildFilters(config) { + let filters = []; + for (const key in config) { + filters.push(this._generateQuery(`/item/${key}`, config[`${key}`])); + } + return filters; + } + + /** + * For a single filter, build filter query + * @param {string} selector + * @param {*} values + */ + _generateQuery(selector, values) { + // TODO: Check for value type + const filters = values.map((value) => `"${selector}" == "${value}"`); + return this._joinFilters(filters, { inclusive: true }); + } + + /** + * Combine filter strings + * @param {array} filters + * @param {object} inclusive + */ + _joinFilters(filters, { inclusive }) { + return filters.join(inclusive ? ' or ' : ' and '); + } +} +export default class FilterableStoreService extends Store { + /** + * Filterable store queries using IDs + * Usage: + * // Filter for a user in sessions + * this.store.filterByIds('session', { scope_id, recursive: true }, { user: ['u_0987654321']}) + * // Filter for status in pending or terminated state and for a session id + * this.store.filterByIds('session', { scope_id }, + * { status: ['pending', 'terminated' ], target: ['s_U5EoFe4Jba']} + * ) + * // To remove filters + * this.store.filterByIds('session', { scope_id }) + * @param {string} modelName + * @param {object} queryOptions + * @param {string} filterQuery + */ + filterByIds(modelName, queryOptions, filterOptions) { + const filterQuery = new FilterQuery(filterOptions); + // Apply filters, if available + if (filterQuery.query) queryOptions.filter = filterQuery; + return this.query(modelName, queryOptions); + } +} diff --git a/addons/api/app/services/filterable-store.js b/addons/api/app/services/filterable-store.js new file mode 100644 index 000000000..c35db1dfc --- /dev/null +++ b/addons/api/app/services/filterable-store.js @@ -0,0 +1 @@ +export { default } from 'api/services/filterable-store'; diff --git a/addons/api/tests/unit/services/filterable-store-test.js b/addons/api/tests/unit/services/filterable-store-test.js new file mode 100644 index 000000000..149d1d992 --- /dev/null +++ b/addons/api/tests/unit/services/filterable-store-test.js @@ -0,0 +1,32 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Service | filterable-store', function (hooks) { + setupTest(hooks); + + let store; + + hooks.beforeEach(function () { + store = this.owner.lookup('service:filterable-store'); + + store.createRecord('account', { + id: 'i_1234567890', + scope: { + id: '123', + }, + }); + }); + + test('it supports query filtering', function (assert) { + tore.filterByIds('account', { scope_id: '123' }); + assert.ok(store); + }); + + test('it supports single attribute filters', function (assert) { + assert.ok(store); + }); + + test('it supports multiple attribute filters', function (assert) { + assert.ok(store); + }); +}); From 8c4a07636748a6250aca1937c18a70fbb616522a Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Sun, 24 Oct 2021 22:18:57 -0400 Subject: [PATCH 2/7] test: Init filter store test for sessions --- .../api/tests/unit/services/filterable-store-test.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/api/tests/unit/services/filterable-store-test.js b/addons/api/tests/unit/services/filterable-store-test.js index 149d1d992..83bc17681 100644 --- a/addons/api/tests/unit/services/filterable-store-test.js +++ b/addons/api/tests/unit/services/filterable-store-test.js @@ -1,15 +1,17 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; +import { Response } from 'miragejs'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; module('Unit | Service | filterable-store', function (hooks) { setupTest(hooks); - + setupMirage(hooks); let store; hooks.beforeEach(function () { store = this.owner.lookup('service:filterable-store'); - store.createRecord('account', { + store.createRecord('session', { id: 'i_1234567890', scope: { id: '123', @@ -18,7 +20,10 @@ module('Unit | Service | filterable-store', function (hooks) { }); test('it supports query filtering', function (assert) { - tore.filterByIds('account', { scope_id: '123' }); + this.server.get('/v1/sessions?scope_id=123', () => { + new Response({}); + }); + store.filterByIds('session', { scope_id: '123' }); assert.ok(store); }); From 82636e3ee99e8366d842d2f81daceda2765d575a Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Mon, 1 Nov 2021 20:23:26 -0400 Subject: [PATCH 3/7] feat: Refactor to ResourceFilteringStore service --- addons/api/addon/services/filterable-store.js | 68 ------------------- .../services/resource-filtering-store.js | 53 +++++++++++++++ addons/api/app/services/filterable-store.js | 1 - .../app/services/resource-filtering-store.js | 1 + .../unit/services/filterable-store-test.js | 37 ---------- .../services/resource-filtering-store-test.js | 29 ++++++++ 6 files changed, 83 insertions(+), 106 deletions(-) delete mode 100644 addons/api/addon/services/filterable-store.js create mode 100644 addons/api/addon/services/resource-filtering-store.js delete mode 100644 addons/api/app/services/filterable-store.js create mode 100644 addons/api/app/services/resource-filtering-store.js delete mode 100644 addons/api/tests/unit/services/filterable-store-test.js create mode 100644 addons/api/tests/unit/services/resource-filtering-store-test.js diff --git a/addons/api/addon/services/filterable-store.js b/addons/api/addon/services/filterable-store.js deleted file mode 100644 index 579e06178..000000000 --- a/addons/api/addon/services/filterable-store.js +++ /dev/null @@ -1,68 +0,0 @@ -import Store from '@ember-data/store'; - -class FilterQuery { - _config; - constructor(config) { - this._config = config; - } - - get query() { - const filters = this._buildFilters(this._config); - return this._joinFilters(filters, { inclusive: false }); - } - - /** - * Iterate through filter config to generate array of filter strings - * @param {object} config - */ - _buildFilters(config) { - let filters = []; - for (const key in config) { - filters.push(this._generateQuery(`/item/${key}`, config[`${key}`])); - } - return filters; - } - - /** - * For a single filter, build filter query - * @param {string} selector - * @param {*} values - */ - _generateQuery(selector, values) { - // TODO: Check for value type - const filters = values.map((value) => `"${selector}" == "${value}"`); - return this._joinFilters(filters, { inclusive: true }); - } - - /** - * Combine filter strings - * @param {array} filters - * @param {object} inclusive - */ - _joinFilters(filters, { inclusive }) { - return filters.join(inclusive ? ' or ' : ' and '); - } -} -export default class FilterableStoreService extends Store { - /** - * Filterable store queries using IDs - * Usage: - * // Filter for a user in sessions - * this.store.filterByIds('session', { scope_id, recursive: true }, { user: ['u_0987654321']}) - * // Filter for status in pending or terminated state and for a session id - * this.store.filterByIds('session', { scope_id }, - * { status: ['pending', 'terminated' ], target: ['s_U5EoFe4Jba']} - * ) - * // To remove filters - * this.store.filterByIds('session', { scope_id }) - * @param {string} modelName - * @param {object} queryOptions - * @param {string} filterQuery - */ - filterByIds(modelName, queryOptions, filterOptions) { - const filterQuery = new FilterQuery(filterOptions); - // Apply filters, if available - if (filterQuery.query) queryOptions.filter = filterQuery; - return this.query(modelName, queryOptions); - } -} diff --git a/addons/api/addon/services/resource-filtering-store.js b/addons/api/addon/services/resource-filtering-store.js new file mode 100644 index 000000000..4f7537c10 --- /dev/null +++ b/addons/api/addon/services/resource-filtering-store.js @@ -0,0 +1,53 @@ +import Service from '@ember/service'; +import { inject as service } from '@ember/service'; + +class ResourceFilters { + buildQuery(resourceFilters) { + const filters = this._buildFilters(resourceFilters); + return this._joinFilters(filters, { inclusive: false }); + } + + /** + * Iterate through filter config to generate array of filter strings + * @param {object} config + */ + _buildFilters(config) { + let filters = []; + for (const key in config) { + filters.push(this._generateQuery(`/item/${key}`, config[`${key}`])); + } + return filters; + } + + /** + * For a single filter, build filter query + * @param {string} selector + * @param {*} values + */ + _generateQuery(selector, values) { + // Coerce single string filters into an array for easy mapping + if (!Array.isArray(values)) values = [values]; + const filters = values.map((value) => `"${selector}" == "${value}"`); + return this._joinFilters(filters, { inclusive: true }); + } + + /** + * Combine filter strings + * @param {array} filters + * @param {object} inclusive + */ + _joinFilters(filters, { inclusive }) { + return filters.join(inclusive ? ' or ' : ' and '); + } +} + +export default class ResourceFilteringStoreService extends Service { + @service store; + + queryBy(modelName, resourceParams, resourceFilters) { + const filterQuery = new ResourceFilters().buildQuery(resourceFilters); + // Apply filters to store query when available + if (filterQuery) resourceParams.filter = filterQuery; + return this.store.query(modelName, resourceParams); + } +} diff --git a/addons/api/app/services/filterable-store.js b/addons/api/app/services/filterable-store.js deleted file mode 100644 index c35db1dfc..000000000 --- a/addons/api/app/services/filterable-store.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'api/services/filterable-store'; diff --git a/addons/api/app/services/resource-filtering-store.js b/addons/api/app/services/resource-filtering-store.js new file mode 100644 index 000000000..13fe8a0c8 --- /dev/null +++ b/addons/api/app/services/resource-filtering-store.js @@ -0,0 +1 @@ +export { default } from 'api/services/resource-filtering-store'; diff --git a/addons/api/tests/unit/services/filterable-store-test.js b/addons/api/tests/unit/services/filterable-store-test.js deleted file mode 100644 index 83bc17681..000000000 --- a/addons/api/tests/unit/services/filterable-store-test.js +++ /dev/null @@ -1,37 +0,0 @@ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; -import { Response } from 'miragejs'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; - -module('Unit | Service | filterable-store', function (hooks) { - setupTest(hooks); - setupMirage(hooks); - let store; - - hooks.beforeEach(function () { - store = this.owner.lookup('service:filterable-store'); - - store.createRecord('session', { - id: 'i_1234567890', - scope: { - id: '123', - }, - }); - }); - - test('it supports query filtering', function (assert) { - this.server.get('/v1/sessions?scope_id=123', () => { - new Response({}); - }); - store.filterByIds('session', { scope_id: '123' }); - assert.ok(store); - }); - - test('it supports single attribute filters', function (assert) { - assert.ok(store); - }); - - test('it supports multiple attribute filters', function (assert) { - assert.ok(store); - }); -}); diff --git a/addons/api/tests/unit/services/resource-filtering-store-test.js b/addons/api/tests/unit/services/resource-filtering-store-test.js new file mode 100644 index 000000000..3e1852d6e --- /dev/null +++ b/addons/api/tests/unit/services/resource-filtering-store-test.js @@ -0,0 +1,29 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Service | resource-filtering-store', function (hooks) { + setupTest(hooks); + let service, store; + hooks.beforeEach(function () { + service = this.owner.lookup('service:resource-filtering-store'); + store = this.owner.lookup('service:store'); + + store.createRecord('session', { + id: 's_1', + scope: { + id: '123', + }, + }); + }); + + // TODO: Replace this with your real tests. + test('it exists', function (assert) { + assert.ok(service); + }); + + // TODO: Is it possible to capture mirage API requests in this test? + // test('it supports query filters', function (assert) { + // const models = service.queryBy('session', {}, { scope_id: '123' }); + // assert.ok(service); + // }); +}); From cd6f87b79682391fd6ded594136c539f563f0a1c Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Mon, 1 Nov 2021 20:25:33 -0400 Subject: [PATCH 4/7] test: Skip WIP test --- .../unit/services/resource-filtering-store-test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/api/tests/unit/services/resource-filtering-store-test.js b/addons/api/tests/unit/services/resource-filtering-store-test.js index 3e1852d6e..a7cc8ad3e 100644 --- a/addons/api/tests/unit/services/resource-filtering-store-test.js +++ b/addons/api/tests/unit/services/resource-filtering-store-test.js @@ -1,4 +1,4 @@ -import { module, test } from 'qunit'; +import { module, test, skip } from 'qunit'; import { setupTest } from 'ember-qunit'; module('Unit | Service | resource-filtering-store', function (hooks) { @@ -22,8 +22,8 @@ module('Unit | Service | resource-filtering-store', function (hooks) { }); // TODO: Is it possible to capture mirage API requests in this test? - // test('it supports query filters', function (assert) { - // const models = service.queryBy('session', {}, { scope_id: '123' }); - // assert.ok(service); - // }); + skip('it supports query filters', function (assert) { + service.queryBy('session', {}, { scope_id: '123' }); + assert.ok(service); + }); }); From 751a72a2d8ed55f139dedc7936dc229c65ae95d4 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Tue, 9 Nov 2021 12:42:39 -0500 Subject: [PATCH 5/7] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20tweak=20resource-fil?= =?UTF-8?q?ter=20service=20and=20apply=20to=20sessions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../addon/services/resource-filter-store.js | 87 +++++++++++++++++++ .../services/resource-filtering-store.js | 53 ----------- .../api/app/services/resource-filter-store.js | 1 + .../app/services/resource-filtering-store.js | 1 - .../services/resource-filter-store-test.js | 18 ++++ .../services/resource-filtering-store-test.js | 29 ------- .../routes/scopes/scope/projects/sessions.js | 4 +- 7 files changed, 108 insertions(+), 85 deletions(-) create mode 100644 addons/api/addon/services/resource-filter-store.js delete mode 100644 addons/api/addon/services/resource-filtering-store.js create mode 100644 addons/api/app/services/resource-filter-store.js delete mode 100644 addons/api/app/services/resource-filtering-store.js create mode 100644 addons/api/tests/unit/services/resource-filter-store-test.js delete mode 100644 addons/api/tests/unit/services/resource-filtering-store-test.js diff --git a/addons/api/addon/services/resource-filter-store.js b/addons/api/addon/services/resource-filter-store.js new file mode 100644 index 000000000..7d4d382ca --- /dev/null +++ b/addons/api/addon/services/resource-filter-store.js @@ -0,0 +1,87 @@ +import Service from '@ember/service'; +import { inject as service } from '@ember/service'; + +/** + * Takes a POJO representing a query and converts it to a boolean expression + * string which is understood by the API. + * + * @example + * const filter = new ResourceFilter({ + * type: 'oidc', + * status: ['active', 'pending'] + * }); + * console.log(filter.queryExpression); + * // ("/item/type" == "oidc") and ("/item/status" == "active" or "/item/status" == "pending") + */ +export class ResourceFilter { + // =attributes + + #filterObject; + + /** + * @type {string} + */ + get queryExpression() { + const clauses = Object.keys(this.#filterObject) + .map((key) => { + const value = this.#filterObject[key]; + const valuesArray = Array.isArray(value) ? value : [value]; + return this.parenthetical( + this.or(valuesArray.map((value) => this.equals(key, value))) + ); + }) + .flat(); + return this.and(clauses); + } + + // =methods + + /** + * @param {object} filterObject + */ + constructor(filterObject = {}) { + this.#filterObject = Object.assign({}, filterObject); + } + + /** + * @param {string} key + * @param value + */ + equals(key, value) { + return `"/item/${key}" == "${value}"`; + } + + /** + * @param {string[]} clauses + */ + and(clauses) { + return clauses.join(' and '); + } + + /** + * @param {string[]} clauses + */ + or(clauses) { + return clauses.join(' or '); + } + + /** + * @param {string} expression + */ + parenthetical(expression) { + return `(${expression})`; + } +} + +export default class ResourceFilterStoreService extends Service { + @service store; + + queryBy(modelName, filterObject = {}, storeQuery = {}) { + console.log(filterObject); + const filter = new ResourceFilter(filterObject); + const query = Object.assign({}, storeQuery); + // Apply filters to store query when available + if (filter.queryExpression) query.filter = filter.queryExpression; + return this.store.query(modelName, query); + } +} diff --git a/addons/api/addon/services/resource-filtering-store.js b/addons/api/addon/services/resource-filtering-store.js deleted file mode 100644 index 4f7537c10..000000000 --- a/addons/api/addon/services/resource-filtering-store.js +++ /dev/null @@ -1,53 +0,0 @@ -import Service from '@ember/service'; -import { inject as service } from '@ember/service'; - -class ResourceFilters { - buildQuery(resourceFilters) { - const filters = this._buildFilters(resourceFilters); - return this._joinFilters(filters, { inclusive: false }); - } - - /** - * Iterate through filter config to generate array of filter strings - * @param {object} config - */ - _buildFilters(config) { - let filters = []; - for (const key in config) { - filters.push(this._generateQuery(`/item/${key}`, config[`${key}`])); - } - return filters; - } - - /** - * For a single filter, build filter query - * @param {string} selector - * @param {*} values - */ - _generateQuery(selector, values) { - // Coerce single string filters into an array for easy mapping - if (!Array.isArray(values)) values = [values]; - const filters = values.map((value) => `"${selector}" == "${value}"`); - return this._joinFilters(filters, { inclusive: true }); - } - - /** - * Combine filter strings - * @param {array} filters - * @param {object} inclusive - */ - _joinFilters(filters, { inclusive }) { - return filters.join(inclusive ? ' or ' : ' and '); - } -} - -export default class ResourceFilteringStoreService extends Service { - @service store; - - queryBy(modelName, resourceParams, resourceFilters) { - const filterQuery = new ResourceFilters().buildQuery(resourceFilters); - // Apply filters to store query when available - if (filterQuery) resourceParams.filter = filterQuery; - return this.store.query(modelName, resourceParams); - } -} diff --git a/addons/api/app/services/resource-filter-store.js b/addons/api/app/services/resource-filter-store.js new file mode 100644 index 000000000..984741e20 --- /dev/null +++ b/addons/api/app/services/resource-filter-store.js @@ -0,0 +1 @@ +export { default } from 'api/services/resource-filter-store'; diff --git a/addons/api/app/services/resource-filtering-store.js b/addons/api/app/services/resource-filtering-store.js deleted file mode 100644 index 13fe8a0c8..000000000 --- a/addons/api/app/services/resource-filtering-store.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'api/services/resource-filtering-store'; diff --git a/addons/api/tests/unit/services/resource-filter-store-test.js b/addons/api/tests/unit/services/resource-filter-store-test.js new file mode 100644 index 000000000..4902d8c5b --- /dev/null +++ b/addons/api/tests/unit/services/resource-filter-store-test.js @@ -0,0 +1,18 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; +import { ResourceFilter } from 'api/services/resource-filter-store'; + +module('Unit | Service | resource-filter-store', function (hooks) { + setupTest(hooks); + + test('it exports a ResourceFilter class that converts filterObjects to query expressions', function (assert) { + assert.ok(ResourceFilter); + const filter = new ResourceFilter({ + type: 'oidc', + status: ['active', 'pending'], + }); + const expected = + '("/item/type" == "oidc") and ("/item/status" == "active" or "/item/status" == "pending")'; + assert.equal(filter.queryExpression, expected); + }); +}); diff --git a/addons/api/tests/unit/services/resource-filtering-store-test.js b/addons/api/tests/unit/services/resource-filtering-store-test.js deleted file mode 100644 index a7cc8ad3e..000000000 --- a/addons/api/tests/unit/services/resource-filtering-store-test.js +++ /dev/null @@ -1,29 +0,0 @@ -import { module, test, skip } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Service | resource-filtering-store', function (hooks) { - setupTest(hooks); - let service, store; - hooks.beforeEach(function () { - service = this.owner.lookup('service:resource-filtering-store'); - store = this.owner.lookup('service:store'); - - store.createRecord('session', { - id: 's_1', - scope: { - id: '123', - }, - }); - }); - - // TODO: Replace this with your real tests. - test('it exists', function (assert) { - assert.ok(service); - }); - - // TODO: Is it possible to capture mirage API requests in this test? - skip('it supports query filters', function (assert) { - service.queryBy('session', {}, { scope_id: '123' }); - assert.ok(service); - }); -}); diff --git a/ui/desktop/app/routes/scopes/scope/projects/sessions.js b/ui/desktop/app/routes/scopes/scope/projects/sessions.js index cd11b0569..799785f5b 100644 --- a/ui/desktop/app/routes/scopes/scope/projects/sessions.js +++ b/ui/desktop/app/routes/scopes/scope/projects/sessions.js @@ -13,6 +13,7 @@ export default class ScopesScopeProjectsSessionsRoute extends Route { @service ipc; @service session; + @service resourceFilterStore; // =attributes @@ -52,8 +53,7 @@ export default class ScopesScopeProjectsSessionsRoute extends Route { const { id: scope_id } = this.modelFor('scopes.scope'); const { user_id } = this.session.data.authenticated; await this.store.query('target', { recursive: true, scope_id }); - return await this.store.query('session', { - filter: `"/item/user_id" == "${user_id}"`, + return await this.resourceFilterStore.queryBy('session', { user_id }, { recursive: true, scope_id }); From d1ce2ac9eab37befdf055e8379118af5cdae7533 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Tue, 9 Nov 2021 13:34:35 -0500 Subject: [PATCH 6/7] docs: improve doc comments --- .../addon/services/resource-filter-store.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/addons/api/addon/services/resource-filter-store.js b/addons/api/addon/services/resource-filter-store.js index 7d4d382ca..98a48f120 100644 --- a/addons/api/addon/services/resource-filter-store.js +++ b/addons/api/addon/services/resource-filter-store.js @@ -16,6 +16,9 @@ import { inject as service } from '@ember/service'; export class ResourceFilter { // =attributes + /** + * @type {?object} + */ #filterObject; /** @@ -46,6 +49,7 @@ export class ResourceFilter { /** * @param {string} key * @param value + * @return {string} */ equals(key, value) { return `"/item/${key}" == "${value}"`; @@ -53,6 +57,7 @@ export class ResourceFilter { /** * @param {string[]} clauses + * @return {string} */ and(clauses) { return clauses.join(' and '); @@ -60,6 +65,7 @@ export class ResourceFilter { /** * @param {string[]} clauses + * @return {string} */ or(clauses) { return clauses.join(' or '); @@ -67,15 +73,32 @@ export class ResourceFilter { /** * @param {string} expression + * @return {string} */ parenthetical(expression) { return `(${expression})`; } } +/** + * + */ export default class ResourceFilterStoreService extends Service { + // =services + @service store; + // =methods + + /** + * Similar to Ember's built-in `store.query`, except this method accepts + * an additional argument `filterObject` representing a query filter + * (see ResourceFilter class above). + * @param {string} modelName + * @param {object} filterObject + * @param {?object} storeQuery + * @return {Promise} + */ queryBy(modelName, filterObject = {}, storeQuery = {}) { console.log(filterObject); const filter = new ResourceFilter(filterObject); From c2ebbcb735a365f3f60e1f858f4bb88175039348 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Tue, 9 Nov 2021 13:50:10 -0500 Subject: [PATCH 7/7] Update addons/api/addon/services/resource-filter-store.js Co-authored-by: Dharini Jeeva --- addons/api/addon/services/resource-filter-store.js | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/api/addon/services/resource-filter-store.js b/addons/api/addon/services/resource-filter-store.js index 98a48f120..94d934359 100644 --- a/addons/api/addon/services/resource-filter-store.js +++ b/addons/api/addon/services/resource-filter-store.js @@ -100,7 +100,6 @@ export default class ResourceFilterStoreService extends Service { * @return {Promise} */ queryBy(modelName, filterObject = {}, storeQuery = {}) { - console.log(filterObject); const filter = new ResourceFilter(filterObject); const query = Object.assign({}, storeQuery); // Apply filters to store query when available