Skip to content

Commit

Permalink
add maxColumns query parameter, #109
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Nov 6, 2020
1 parent 4c6a314 commit 4b22108
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions js/report/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const options = QueryStringMachine.getAll( {

// Origin for our server (ignoring current port), so that we don't require localhost
defaultValue: window.location.protocol + '//' + window.location.hostname
},
maxColumns: {
type: 'number',
defaultValue: -1 // when -1, will show all columns
}
} );

Expand Down Expand Up @@ -81,7 +85,7 @@ statusProperty.lazyLink( status => console.log( `Status: ${status}` ) );

// {Property.<Object|null>}
const reportProperty = new Property( {
snapshots: [],
snapshots: [], // latest snapshots first
testNames: [],
testAverageTimes: [],
testWeights: []
Expand Down Expand Up @@ -324,6 +328,11 @@ Property.multilink( [ reportProperty, expandedReposProperty, sortProperty, filte
( report, expandedRepos, sort, filterString, showAverageTime, showWeights ) => {
let tests = [];

let snapshots = report.snapshots;
if ( options.maxColumns === -1 ) {
snapshots = snapshots.filter( ( snapshot, index ) => index < options.maxColumns );
}

const everythingName = '(everything)';

tests.push( {
Expand Down Expand Up @@ -377,8 +386,8 @@ Property.multilink( [ reportProperty, expandedReposProperty, sortProperty, filte

if ( sort === Sort.IMPORTANCE ) {
tests = _.sortBy( tests, test => {
const failIndex = _.findIndex( report.snapshots, snapshot => _.some( test.indices, index => snapshot.tests[ index ].n ) );
const passIndex = _.findIndex( report.snapshots, snapshot => _.some( test.indices, index => snapshot.tests[ index ].y ) );
const failIndex = _.findIndex( snapshots, snapshot => _.some( test.indices, index => snapshot.tests[ index ].n ) );
const passIndex = _.findIndex( snapshots, snapshot => _.some( test.indices, index => snapshot.tests[ index ].y ) );
if ( failIndex >= 0 ) {
return failIndex;
}
Expand Down Expand Up @@ -466,7 +475,7 @@ Property.multilink( [ reportProperty, expandedReposProperty, sortProperty, filte

const padding = 3;

const snapshotLabels = report.snapshots.map( ( snapshot, index ) => {
const snapshotLabels = snapshots.map( ( snapshot, index ) => {
const label = new VBox( {
spacing: 2,
children: [
Expand All @@ -478,7 +487,7 @@ Property.multilink( [ reportProperty, expandedReposProperty, sortProperty, filte
fire: () => {
let diffString = '';

const previousSnapshot = report.snapshots[ index + 1 ];
const previousSnapshot = snapshots[ index + 1 ];
if ( previousSnapshot ) {
diffString = _.uniq( Object.keys( snapshot.shas ).concat( Object.keys( previousSnapshot.shas ) ) ).sort().filter( repo => {
return snapshot.shas[ repo ] !== previousSnapshot.shas[ repo ];
Expand Down Expand Up @@ -522,7 +531,7 @@ Property.multilink( [ reportProperty, expandedReposProperty, sortProperty, filte
const getX = index => maxTestLabelWidth + padding + index * ( maxSnapshotLabelWidth + padding ) + ( showAverageTime ? 1 : 0 ) * ( maxAverageTimeLabelWidth + padding ) + ( showWeights ? 1 : 0 ) * ( maxWeightLabelWidth + padding );
const getY = index => maxSnapshotLabelHeight + padding + index * ( maxTestLabelHeight + padding );

const snapshotsTestNodes = _.flatten( report.snapshots.map( ( snapshot, i ) => {
const snapshotsTestNodes = _.flatten( snapshots.map( ( snapshot, i ) => {
return tests.map( ( test, j ) => {
const x = getX( i );
const y = getY( j );
Expand Down

0 comments on commit 4b22108

Please sign in to comment.