1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

cache last job_event page when not running

This commit is contained in:
Jake McDermott 2018-06-26 11:41:08 -04:00
parent 7f23aa81e6
commit 47fc676607
No known key found for this signature in database
GPG Key ID: 3B02CAD476EECB35
2 changed files with 19 additions and 1 deletions

View File

@ -15,9 +15,21 @@ function JobEventsApiService ($http, $q) {
this.params = merge(BASE_PARAMS, params);
this.state = { count: 0, maxCounter: 0 };
this.cache = {};
};
this.fetch = () => this.getLast().then(() => this);
this.clearCache = () => {
Object.keys(this.cache).forEach(key => {
delete this.cache[key];
});
};
this.fetch = () => this.getLast()
.then(results => {
this.cache.last = results;
return this;
});
this.getFirst = () => {
const page = 1;
@ -61,6 +73,10 @@ function JobEventsApiService ($http, $q) {
};
this.getLast = () => {
if (this.cache.last) {
return $q.resolve(this.cache.last);
}
const params = merge(this.params, { page: 1, order_by: `-${ORDER_BY}` });
return $http.get(this.endpoint, { params })

View File

@ -102,6 +102,8 @@ function SlidingWindowService ($q) {
this.records = {};
this.uuids = {};
this.chain = $q.resolve();
api.clearCache();
};
this.pushFront = events => {