From 0bf44f3b506588ebbf78c25a802563882da72f50 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Tue, 13 Jun 2023 12:09:14 +0100 Subject: [PATCH] Label profile data with baseline and change commits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - and handle the case that there’s no trialId --- src/views/compare.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/views/compare.ts b/src/views/compare.ts index e0ae5464..9cbca329 100644 --- a/src/views/compare.ts +++ b/src/views/compare.ts @@ -102,16 +102,25 @@ function createEntry(e, profId, counter) { return entryHtml; } -function fetchProfile(projectSlug: string, change, runId, trialId, jqInsert) { +function fetchProfile( + projectSlug: string, + commitId: string, + isBase: boolean, + runId: number, + trialId: number, + jqInsert: JQuery +) { const profileP = fetch( `/rebenchdb/dash/${projectSlug}/profiles/${runId}/${trialId}` ); profileP.then(async (profileResponse) => { const profileData = await profileResponse.json(); - const profId = `prof-${change}-${runId}-${trialId}`; + const profId = `prof-${commitId}-${runId}-${trialId}`; const container = jqInsert.children(); - let mainContent = `
`; + const labelClass = isBase ? 'baseline' : 'change'; + const label = `${commitId}`; + let mainContent = `${label}
`; const counter = { cnt: 0 }; for (const e of profileData.profile) { @@ -156,6 +165,8 @@ function parseDataSeriesIds(serialized: string): DataSeriesIds { function insertProfiles(e): void { const projectSlug = $('#project-slug').attr('value'); + const baseHash = $('#baseHash').attr('value'); + const jqButton = $(e.target); let profileInsertTarget = jqButton.parent().parent(); jqButton.remove(); @@ -163,12 +174,17 @@ function insertProfiles(e): void { const { runId, ids } = parseDataSeriesIds(jqButton.data('content')); for (const { commitId, trialId } of ids) { + if (isNaN(trialId)) { + continue; + } + const jqInsert = $( `` ); profileInsertTarget.after(jqInsert); profileInsertTarget = jqInsert; - fetchProfile(projectSlug, commitId, runId, trialId, jqInsert); + const isBase = baseHash?.startsWith(commitId) ?? false; + fetchProfile(projectSlug, commitId, isBase, runId, trialId, jqInsert); } }