-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simplified tabify #19061
simplified tabify #19061
Changes from 6 commits
05616c8
782b7b7
d1fbdcd
eb8fe8e
ae1b902
ec821ee
75cb639
2342dd1
0ac4ed6
aafcd01
7cb2e56
662eca8
37f13e5
d304c79
6a74f00
d083735
a346d76
8173c32
aa54b93
dc23e88
dd09305
9ab1e66
5fc0cd5
baabce5
9e4e786
d964ffc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,23 +24,27 @@ import { tabifyGetColumns } from './_get_columns'; | |
* Writer class that collects information about an aggregation response and | ||
* produces a table, or a series of tables. | ||
* | ||
* @param {Vis} vis - the vis object to which the aggregation response correlates | ||
* @param {AggConfigs} aggs - the agg configs object to which the aggregation response correlates | ||
* @param {boolean} minimalColumns - setting to false will produce metrics for every bucket | ||
*/ | ||
This comment was marked as resolved.
Sorry, something went wrong. |
||
function TabbedAggResponseWriter(aggs, opts) { | ||
this.opts = opts || {}; | ||
function TabbedAggResponseWriter(aggs, { metricsAtAllLevels = false, partialRows = false }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That way it will also work if the user didn't specify a 2nd parameter at all. |
||
this.rowBuffer = {}; | ||
this.bucketBuffer = []; | ||
this.metricBuffer = []; | ||
|
||
// by default minimalColumns is set to true | ||
this.opts.minimalColumns = !(this.opts.minimalColumns === false); | ||
|
||
this.metricsForAllBuckets = metricsAtAllLevels; | ||
this.partialRows = partialRows; | ||
this.aggs = aggs; | ||
this.columns = tabifyGetColumns(aggs.getResponseAggs(), this.opts.minimalColumns); | ||
this.columns = tabifyGetColumns(aggs.getResponseAggs(), !metricsAtAllLevels); | ||
this.aggStack = [...this.columns]; | ||
|
||
this.rows = []; | ||
} | ||
|
||
TabbedAggResponseWriter.prototype.isPartialRow = function (row) { | ||
return !this.columns.map(column => row.hasOwnProperty(column.id)).every(c => (c === true)); | ||
}; | ||
|
||
/** | ||
* Create a new row by reading the row buffer and bucketBuffer | ||
*/ | ||
|
@@ -49,7 +53,11 @@ TabbedAggResponseWriter.prototype.row = function () { | |
this.rowBuffer[bucket.id] = bucket.value; | ||
}); | ||
|
||
if (!toArray(this.rowBuffer).length) { | ||
this.metricBuffer.forEach(metric => { | ||
this.rowBuffer[metric.id] = metric.value; | ||
}); | ||
|
||
if (!toArray(this.rowBuffer).length || (!this.partialRows && this.isPartialRow(this.rowBuffer))) { | ||
return; | ||
} | ||
|
||
|
@@ -60,7 +68,7 @@ TabbedAggResponseWriter.prototype.row = function () { | |
/** | ||
* Get the actual response | ||
* | ||
* @return {object} - the final table-tree | ||
* @return {object} - the final table | ||
*/ | ||
TabbedAggResponseWriter.prototype.response = function () { | ||
return { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ describe('Vislib Vis Type', function () { | |
describe('initialization', () => { | ||
it('should set the basic response handler if not set', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const visType = new VislibVisType(visConfig); | ||
expect(visType.responseHandler).to.equal('basic'); | ||
expect(visType.responseHandler).to.equal('vislib'); | ||
}); | ||
|
||
it('should not change response handler if its already set', () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs adjustements to the new parameters
partialRows
andmetricsAtAllLevels
now.