-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement basic build measurements UI
- Loading branch information
1 parent
1e44e4f
commit a1f2477
Showing
8 changed files
with
219 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
database/migrations/2024_10_14_183851_buildmeasurements_unique_buildid_source_type_name.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration { | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('buildmeasurements', function (Blueprint $table) { | ||
$table->unique(['buildid', 'source', 'type', 'name']); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('buildmeasurements', function (Blueprint $table) { | ||
$table->dropUnique(['buildid', 'source', 'type', 'name']); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
<template> | ||
<div class="tw-flex tw-flex-col tw-w-full tw-gap-4"> | ||
<filter-builder | ||
filter-type="BuildMeasurementsFiltersMultiFilterInput" | ||
primary-record-name="build measurements" | ||
:initial-filters="initialFilters" | ||
:execute-query-link="executeQueryLink" | ||
@changeFilters="filters => changedFilters = filters" | ||
/> | ||
<loading-indicator :is-loading="!build"> | ||
<data-table | ||
:columns="columns" | ||
:rows="formattedMeasurementRows" | ||
:full-width="true" | ||
initial-sort-column="source" | ||
/> | ||
</loading-indicator> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import DataTable from './shared/DataTable.vue'; | ||
import gql from 'graphql-tag'; | ||
import FilterBuilder from './shared/FilterBuilder.vue'; | ||
import LoadingIndicator from './shared/LoadingIndicator.vue'; | ||
export default { | ||
components: { | ||
LoadingIndicator, | ||
FilterBuilder, | ||
DataTable, | ||
}, | ||
props: { | ||
buildId: { | ||
type: Number, | ||
required: true, | ||
}, | ||
initialFilters: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
apollo: { | ||
build: { | ||
query: gql` | ||
query($buildid: ID, $filters: BuildMeasurementsFiltersMultiFilterInput, $after: String) { | ||
build(id: $buildid) { | ||
measurements(filters: $filters, after: $after, first: 100) { | ||
edges { | ||
node { | ||
id | ||
name | ||
source | ||
type | ||
value | ||
} | ||
} | ||
pageInfo { | ||
hasNextPage | ||
hasPreviousPage | ||
startCursor | ||
endCursor | ||
} | ||
} | ||
} | ||
} | ||
`, | ||
variables() { | ||
return { | ||
buildid: this.buildId, | ||
filters: this.initialFilters, | ||
after: '', | ||
}; | ||
}, | ||
result({data}) { | ||
if (data && data.build.measurements.pageInfo.hasNextPage) { | ||
this.$apollo.queries.build.fetchMore({ | ||
variables: { | ||
after: data.build.measurements.pageInfo.endCursor, | ||
}, | ||
}); | ||
} | ||
}, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
changedFilters: JSON.parse(JSON.stringify(this.initialFilters)), | ||
}; | ||
}, | ||
computed: { | ||
executeQueryLink() { | ||
return `${window.location.origin}${window.location.pathname}?filters=${encodeURIComponent(JSON.stringify(this.changedFilters))}`; | ||
}, | ||
columns() { | ||
const uniqueMeasurements = [...new Set(this.build.measurements.edges.map(edge => { | ||
return edge.node.name; | ||
}))]; | ||
const columns = [ | ||
{ | ||
name: 'source', | ||
displayName: 'Source', | ||
expand: true, | ||
}, | ||
{ | ||
name: 'type', | ||
displayName: 'Type', | ||
}, | ||
]; | ||
uniqueMeasurements.forEach(element => { | ||
columns.push({ | ||
name: `measurement_${element}`, | ||
displayName: element, | ||
}); | ||
}); | ||
return columns; | ||
}, | ||
formattedMeasurementRows() { | ||
// A mapping of the form: source_type => {row object} | ||
const source_type_pairs = {}; | ||
this.build.measurements.edges.forEach(edge => { | ||
const key = `${edge.node.source}_${edge.node.type}`; | ||
if (!source_type_pairs.hasOwnProperty(key)) { | ||
source_type_pairs[key] = { | ||
source: edge.node.source, | ||
type: edge.node.type, | ||
}; | ||
} | ||
source_type_pairs[key][`measurement_${edge.node.name}`] = { | ||
value: isNaN(edge.node.value) ? edge.node.value : Number(edge.node.value), | ||
text: edge.node.value, | ||
}; | ||
}); | ||
return Object.values(source_type_pairs); | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@extends('cdash', [ | ||
'vue' => true, | ||
'daisyui' => true, | ||
]) | ||
|
||
@section('main_content') | ||
<build-measurements-page :build-id="{{ $build->Id }}" :initial-filters="@js($filters)"></build-measurements-page> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* TODO: Fill out this test once seed data for the build measurements functionality becomes available. | ||
* For now, we just verify that the page loads with no errors. | ||
*/ | ||
describe('Build measurements page', () => { | ||
it('Loads page successfully', () => { | ||
cy.visit('/builds/372/measurements'); | ||
cy.get('#headername2').should('not.contain', '404 Not Found'); | ||
}); | ||
|
||
it('Shows 404 if build does not exist', () => { | ||
cy.visit('/builds/12345678/measurements'); | ||
cy.get('#headername2').should('contain', '404 Not Found'); | ||
}); | ||
}); |