mirror of
https://github.com/ansible/awx.git
synced 2026-03-05 10:41:05 -03:30
cache last job_event page when not running
This commit is contained in:
@@ -15,9 +15,21 @@ function JobEventsApiService ($http, $q) {
|
|||||||
this.params = merge(BASE_PARAMS, params);
|
this.params = merge(BASE_PARAMS, params);
|
||||||
|
|
||||||
this.state = { count: 0, maxCounter: 0 };
|
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 = () => {
|
this.getFirst = () => {
|
||||||
const page = 1;
|
const page = 1;
|
||||||
@@ -61,6 +73,10 @@ function JobEventsApiService ($http, $q) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.getLast = () => {
|
this.getLast = () => {
|
||||||
|
if (this.cache.last) {
|
||||||
|
return $q.resolve(this.cache.last);
|
||||||
|
}
|
||||||
|
|
||||||
const params = merge(this.params, { page: 1, order_by: `-${ORDER_BY}` });
|
const params = merge(this.params, { page: 1, order_by: `-${ORDER_BY}` });
|
||||||
|
|
||||||
return $http.get(this.endpoint, { params })
|
return $http.get(this.endpoint, { params })
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ function SlidingWindowService ($q) {
|
|||||||
this.records = {};
|
this.records = {};
|
||||||
this.uuids = {};
|
this.uuids = {};
|
||||||
this.chain = $q.resolve();
|
this.chain = $q.resolve();
|
||||||
|
|
||||||
|
api.clearCache();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.pushFront = events => {
|
this.pushFront = events => {
|
||||||
|
|||||||
Reference in New Issue
Block a user