Skip to content

Commit

Permalink
Label profile data with baseline and change commits
Browse files Browse the repository at this point in the history
- and handle the case that there’s no trialId
  • Loading branch information
smarr committed Jun 13, 2023
1 parent 6f6f612 commit 0bf44f3
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/views/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLElement>
) {
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 = `<div class="list-group list-group-root">`;
const labelClass = isBase ? 'baseline' : 'change';
const label = `<span class="${labelClass}-badge">${commitId}</span>`;
let mainContent = `${label}<div class="list-group list-group-root">`;

const counter = { cnt: 0 };
for (const e of profileData.profile) {
Expand Down Expand Up @@ -156,19 +165,26 @@ function parseDataSeriesIds(serialized: string): DataSeriesIds {

function insertProfiles(e): void {
const projectSlug = <string>$('#project-slug').attr('value');
const baseHash = $('#baseHash').attr('value');

const jqButton = $(e.target);
let profileInsertTarget = jqButton.parent().parent();
jqButton.remove();

const { runId, ids } = parseDataSeriesIds(jqButton.data('content'));

for (const { commitId, trialId } of ids) {
if (isNaN(trialId)) {
continue;
}

const jqInsert = $(
`<tr><td class="profile-container" colspan="6"></td></tr>`
);
profileInsertTarget.after(jqInsert);
profileInsertTarget = jqInsert;
fetchProfile(projectSlug, commitId, runId, trialId, jqInsert);
const isBase = baseHash?.startsWith(commitId) ?? false;
fetchProfile(projectSlug, commitId, isBase, runId, trialId, jqInsert);
}
}

Expand Down

0 comments on commit 0bf44f3

Please sign in to comment.