I am trying to access the pagination variables in the response such as page_number, total_pages inside my controller as I have introduced this feature just now to this legacy code in the backend and now I am stuck how can I read those data and go further.
My serializer code
import DS from 'ember-data';
var underscore = Ember.String.underscore;
export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
rules: {
embedded: 'always'
},
test_cases: {
serialize: "id",
deserialize: 'records'
},
},
keyForRelationship: function (rawKey) {
return underscore(rawKey) + "_id";
}
})
route.js
import Route from '@ember/routing/route';
import { hash } from 'rsvp'
import ResetScrollMixin from 'admin-frontend/mixins/reset-scroll-mixin'
export default Route.extend(ResetScrollMixin, {
model(params) {
return hash({
ruleSetVersions: this.store.query('rule-set-version', {
rule_set_id: params.rule_set_id,
is_archived: false,
page: '1'
}),
ruleSet: this.store.findRecord('rule-set', params.rule_set_id)
})
}
});
And response json looks like
{
"page_number": 1,
"page_size": 5,
"rule_set_versions": [{
"id": 930,
"last_updated_by": 1,
"created_by": 1,
"default_rule_id": 963,
"is_live": true,
"is_archived": false,
"start_time": "2020-12-30T18:30:00Z",
"rule_set_id": 11,
"rules": [{
"id": 963,
"priority": 10000001,
"conditions": [],
"results": [{
"id": 59,
"operator": null,
"value": "00",
"rule_id": 963,
"rule_set_metadatum": {
"created_at": "2020-11-18T10:01:38Z",
"datatype": "integer",
"id": 34,
"name": "edd_result",
"property_category": "result",
"updated_at": "2020-11-18T10:01:38Z",
"validations": {
"max": 99999,
"min": 0
}
},
"created_at": "2020-11-18T10:10:41Z",
"updated_at": "2020-11-18T10:10:41Z"
}],
"created_at": "2020-11-18T10:10:32Z",
"updated_at": "2020-11-18T10:10:32Z"
}, {
"id": 971,
"priority": 1,
"conditions": [{
"id": 57,
"comparator": "equal_to",
"value": "100",
"rule_id": 971,
"rule_set_metadatum": {
"created_at": "2020-11-18T10:01:05Z",
"datatype": "text",
"id": 33,
"name": "edd_con",
"property_category": "condition",
"updated_at": "2020-11-18T10:01:05Z",
"validations": {}
},
"created_at": "2020-12-23T09:05:04Z",
"updated_at": "2020-12-23T09:05:04Z"
}],
"results": [{
"id": 66,
"operator": null,
"value": "100",
"rule_id": 971,
"rule_set_metadatum": {
"created_at": "2020-11-18T10:01:38Z",
"datatype": "integer",
"id": 34,
"name": "edd_result",
"property_category": "result",
"updated_at": "2020-11-18T10:01:38Z",
"validations": {
"max": 99999,
"min": 0
}
},
"created_at": "2020-12-23T09:05:10Z",
"updated_at": "2020-12-23T09:05:10Z"
}],
"created_at": "2020-12-23T09:04:54Z",
"updated_at": "2020-12-23T09:04:54Z"
}],
"created_at": "2020-11-18T10:10:32Z",
"updated_at": "2020-12-23T09:06:04Z"
}, {
"id": 932,
"last_updated_by": 1,
"created_by": 1,
"default_rule_id": 969,
"is_live": true,
"is_archived": false,
"start_time": "2020-11-25T18:30:00Z",
"rule_set_id": 11,
"rules": [{
"id": 969,
"priority": 10000001,
"conditions": [],
"results": [{
"id": 64,
"operator": null,
"value": "1000",
"rule_id": 969,
"rule_set_metadatum": {
"created_at": "2020-11-18T10:01:38Z",
"datatype": "integer",
"id": 34,
"name": "edd_result",
"property_category": "result",
"updated_at": "2020-11-18T10:01:38Z",
"validations": {
"max": 99999,
"min": 0
}
},
"created_at": "2020-11-25T11:53:58Z",
"updated_at": "2020-11-25T11:53:58Z"
}],
"created_at": "2020-11-25T11:53:49Z",
"updated_at": "2020-11-25T11:53:49Z"
}, {
"id": 970,
"priority": 1,
"conditions": [{
"id": 56,
"comparator": "equal_to",
"value": "100",
"rule_id": 970,
"rule_set_metadatum": {
"created_at": "2020-11-18T10:01:05Z",
"datatype": "text",
"id": 33,
"name": "edd_con",
"property_category": "condition",
"updated_at": "2020-11-18T10:01:05Z",
"validations": {}
},
"created_at": "2020-11-25T11:54:11Z",
"updated_at": "2020-11-25T11:54:11Z"
}],
"results": [{
"id": 65,
"operator": null,
"value": "100",
"rule_id": 970,
"rule_set_metadatum": {
"created_at": "2020-11-18T10:01:38Z",
"datatype": "integer",
"id": 34,
"name": "edd_result",
"property_category": "result",
"updated_at": "2020-11-18T10:01:38Z",
"validations": {
"max": 99999,
"min": 0
}
},
"created_at": "2020-11-25T11:54:16Z",
"updated_at": "2020-11-25T11:54:16Z"
}],
"created_at": "2020-11-25T11:54:03Z",
"updated_at": "2020-11-25T11:54:03Z"
}],
"created_at": "2020-11-25T11:53:49Z",
"updated_at": "2020-11-25T11:55:12Z"
}, {
"id": 934,
"last_updated_by": 1,
"created_by": 1,
"default_rule_id": 974,
"is_live": false,
"is_archived": false,
"start_time": "2020-12-30T18:30:00Z",
"rule_set_id": 11,
"rules": [{
"id": 974,
"priority": 10000001,
"conditions": [],
"results": [{
"id": 69,
"operator": null,
"value": "00",
"rule_id": 974,
"rule_set_metadatum": {
"created_at": "2020-11-18T10:01:38Z",
"datatype": "integer",
"id": 34,
"name": "edd_result",
"property_category": "result",
"updated_at": "2020-11-18T10:01:38Z",
"validations": {
"max": 99999,
"min": 0
}
},
"created_at": "2021-03-11T10:55:44Z",
"updated_at": "2021-03-11T10:55:44Z"
}],
"created_at": "2021-03-11T10:55:44Z",
"updated_at": "2021-03-11T10:55:44Z"
}, {
"id": 976,
"priority": 1,
"conditions": [{
"id": 60,
"comparator": "equal_to",
"value": "100",
"rule_id": 976,
"rule_set_metadatum": {
"created_at": "2020-11-18T10:01:05Z",
"datatype": "text",
"id": 33,
"name": "edd_con",
"property_category": "condition",
"updated_at": "2020-11-18T10:01:05Z",
"validations": {}
},
"created_at": "2021-03-12T16:18:04Z",
"updated_at": "2021-03-12T16:18:04Z"
}],
"results": [{
"id": 71,
"operator": null,
"value": "100",
"rule_id": 976,
"rule_set_metadatum": {
"created_at": "2020-11-18T10:01:38Z",
"datatype": "integer",
"id": 34,
"name": "edd_result",
"property_category": "result",
"updated_at": "2020-11-18T10:01:38Z",
"validations": {
"max": 99999,
"min": 0
}
},
"created_at": "2021-03-12T16:18:10Z",
"updated_at": "2021-03-12T16:18:10Z"
}],
"created_at": "2021-03-12T16:17:55Z",
"updated_at": "2021-03-12T16:17:55Z"
}],
"created_at": "2021-03-11T10:55:44Z",
"updated_at": "2021-03-11T10:55:44Z"
}],
"total_entries": 3,
"total_pages": 1
}
I am able to read and parse all the data inside the rule_set_versions array but I am unable to access the pagination params that are out side it.
Ember noob here.