[tricium plugin] Stop requesting updates after first update
For now, we show a link to a run page instead of actual run results.
To decrease the number of Progress requests, we can stop requesting
once we have the run ID.
Change-Id: I251b4d0e01657c59cfd01292d95e3d3213156b27
Reviewed-on: https://chromium-review.googlesource.com/c/1347411
Reviewed-by: Marc-Antoine Ruel <maruel@chromium.org>
Auto-Submit: Quinten Yearsley <qyearsley@chromium.org>
diff --git a/src/main/resources/static/tricium-view.js b/src/main/resources/static/tricium-view.js
index 124c8ed..322f3ed 100644
--- a/src/main/resources/static/tricium-view.js
+++ b/src/main/resources/static/tricium-view.js
@@ -131,9 +131,6 @@
this._clearUpdateTimeout();
// If all analyzers are finished, then the results won't change
// again for this patch set.
- // TODO(qyearsley): If we don't want to show per-analyzer
- // results, we can actually stop updating as soon as we
- // get the run ID the first time there are real results.
if (this._isDone()) {
return;
}
@@ -150,22 +147,15 @@
},
/**
- * Check whether the Tricium analyzers are all finished.
+ * Check whether we are done requesting results from Tricium.
*
- * The Tricium workflow is generated all at once before it is started, so
- * once it is non-empty, we assume that there will be no additional
- * analyzers in later responses.
+ * Since we just show a run ID with a link, we are done as soon
+ * as we get any valid response.
*
- * @return {Boolean} True if the Tricium run is finished, false otherwise.
+ * @return {Boolean} True when we are done requesting results.
*/
_isDone() {
- if (!this._response) {
- return false;
- }
- // The state is considered "done" if it is not pending or running.
- // Finished states include canceled, aborted, failure, or success.
- const state = this._response.state;
- return state && state != 'PENDING' && state != 'RUNNING';
+ return Boolean(this._response && this._response.runId);
},
_handleVisibilityChange(e) {
diff --git a/test/tricium-view_test.html b/test/tricium-view_test.html
index e31eb9c..ac34f4c 100644
--- a/test/tricium-view_test.html
+++ b/test/tricium-view_test.html
@@ -122,17 +122,19 @@
assert.isFalse(element._isDone());
});
- test('_isDone returns false when state is pending/running', () => {
- element._response = {state: 'PENDING'};
+ test('_isDone returns false with an empty response', () => {
+ element._response = {};
assert.isFalse(element._isDone());
- element._response = {state: 'RUNNING'};
+ element._response = {runId: 0};
assert.isFalse(element._isDone());
});
- test('_isDone returns true when state is success/failure', () => {
- element._response = {state: 'SUCCESS'};
+ test('_isDone returns true when there is a run ID', () => {
+ element._response = {runId: 123, state: 'SUCCESS'};
assert.isTrue(element._isDone());
- element._response = {state: 'FAILURE'};
+ element._response = {runId: 123, state: 'FAILURE'};
+ assert.isTrue(element._isDone());
+ element._response = {runId: 123};
assert.isTrue(element._isDone());
});
});