Skip to content

Commit

Permalink
Merge pull request #288 from bitovi/TR-214
Browse files Browse the repository at this point in the history
attempts to fix TR-214
  • Loading branch information
justinbmeyer authored Jan 21, 2025
2 parents d8b87ca + cf46fbb commit d589345
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ export class TimelineConfiguration extends StacheElement {
<div class="{{^ eq(this.routeData.showSettings, "TIMING")}}hidden{{/}}">
${GOBACK_BUTTON}
<timing-calculation
jiraHelpers:from="this.jiraHelpers"
issueTimingCalculations:to="this.issueTimingCalculations"></timing-calculation>
jiraHelpers:from="this.jiraHelpers"></timing-calculation>
</div>
Expand All @@ -199,9 +198,6 @@ export class TimelineConfiguration extends StacheElement {
}
},

// from children
issueTimingCalculations: null,

// VALUES DERIVING FROM THE `jql`

// PROPERTIES DERIVING FROM `derivedIssues`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

export const calculationKeysToNames = {
parentFirstThenChildren: function(parent, child){
return `From ${parent.type}, then ${child.plural}`
},
childrenOnly: function(parent, child){
return `From ${child.plural}`
},
childrenFirstThenParent: function(parent, child){
return `From ${child.plural}, then ${parent.type}`
},
widestRange: function(parent, child){
return `From ${parent.type} or ${child.plural} (earliest to latest)`
},
parentOnly: function(parent, child){
return `From ${parent.type}`
}
}

export function createBaseLevels(issueHierarchy) {
return issueHierarchy.map((issue)=> {
return {
type: issue.name,
source: issue,
plural: issue.name+"s",
hierarchyLevel: issue.hierarchyLevel
}
});
}

export function calculationsForLevel(parent, child, selected, last){
if(!last) {
return Object.keys(calculationKeysToNames).map( calculationName => {
return {
parent: parent.type,
child: child.type,
calculation: calculationName,
name: calculationKeysToNames[calculationName](parent, child),
selected: selected ? selected === calculationName : "widestRange" === calculationName
}
})
} else {
return [{
parent: parent.type,
child: null,
calculation: "parentOnly",
name: calculationKeysToNames.parentOnly(parent),
selected: true
}];
}
}

/*
return {
child: issueTypeName,
parent: issueType.type,
calculation: calculationName, name: calculationKeysToNames[calculationName](issueType, typeToIssueType[issueTypeName]) }
*/

/**
*
* @param {TimingCalculationsMap} issueTypeMap
* @param {string} primaryIssueType
* @param {Array<TimingCalculation>} timingCalculations
* @returns
*/
// TODO: this is a duplicate function, any change needs to find the other one
export function getTimingLevels(issueHierarchy, timingCalculations){


const baseLevels = createBaseLevels(issueHierarchy);

return baseLevels.map( (level, i)=> {
const child = baseLevels[i+1];
const isLast = i === baseLevels.length - 1;

return {
...level,
childType: child ? child.type : null,
calculations: calculationsForLevel(level, child, timingCalculations[level.type], isLast)
}
});

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import routeData from "../../../routing/route-data.js";
const selectStyle = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"


import {getTimingLevels} from "./helpers.js";

const DEFAULT_CALCULATION_METHOD = "widestRange";

export class TimingCalculation extends StacheElement {
Expand Down Expand Up @@ -42,10 +44,7 @@ export class TimingCalculation extends StacheElement {
}
},
get jiraIssueHierarchyPromise(){
return getSimplifiedIssueHierarchy({
isLoggedIn: this.jiraHelpers.hasValidAccessToken(),
jiraHelpers: this.jiraHelpers,
})
return this.routeData.simplifiedIssueHierarchyPromise;
},
issueHierarchy: {
async(resolve){
Expand All @@ -59,20 +58,6 @@ export class TimingCalculation extends StacheElement {
const allLevels = getTimingLevels(this.issueHierarchy, this.routeData.timingCalculations);
return allLevels.slice(0, allLevels.length - 1);
}
},
get issueTimingCalculations(){
if(!this.issueHierarchy) {
return [];
} else {
const allLevels = getTimingLevels(this.issueHierarchy, this.routeData.timingCalculations);
return allLevels.map( level => {
return {
type: level.type,
hierarchyLevel: level.hierarchyLevel,
calculation: level.calculations.find( (level) => level.selected).calculation
}
})
}
}
}

Expand Down Expand Up @@ -124,89 +109,8 @@ function getIssueHierarchy(types){
*/


export const calculationKeysToNames = {
parentFirstThenChildren: function(parent, child){
return `From ${parent.type}, then ${child.plural}`
},
childrenOnly: function(parent, child){
return `From ${child.plural}`
},
childrenFirstThenParent: function(parent, child){
return `From ${child.plural}, then ${parent.type}`
},
widestRange: function(parent, child){
return `From ${parent.type} or ${child.plural} (earliest to latest)`
},
parentOnly: function(parent, child){
return `From ${parent.type}`
}
}

function createBaseLevels(issueHierarchy) {
return issueHierarchy.map((issue)=> {
return {
type: issue.name,
source: issue,
plural: issue.name+"s",
hierarchyLevel: issue.hierarchyLevel
}
});
}

function calculationsForLevel(parent, child, selected, last){
if(!last) {
return Object.keys(calculationKeysToNames).map( calculationName => {
return {
parent: parent.type,
child: child.type,
calculation: calculationName,
name: calculationKeysToNames[calculationName](parent, child),
selected: selected ? selected === calculationName : "widestRange" === calculationName
}
})
} else {
return [{
parent: parent.type,
child: null,
calculation: "parentOnly",
name: calculationKeysToNames.parentOnly(parent),
selected: true
}];
}
}

/*
return {
child: issueTypeName,
parent: issueType.type,
calculation: calculationName, name: calculationKeysToNames[calculationName](issueType, typeToIssueType[issueTypeName]) }
*/

/**
*
* @param {TimingCalculationsMap} issueTypeMap
* @param {string} primaryIssueType
* @param {Array<TimingCalculation>} timingCalculations
* @returns
*/
function getTimingLevels(issueHierarchy, timingCalculations){


const baseLevels = createBaseLevels(issueHierarchy);

return baseLevels.map( (level, i)=> {
const child = baseLevels[i+1];
const isLast = i === baseLevels.length - 1;

return {
...level,
childType: child ? child.type : null,
calculations: calculationsForLevel(level, child, timingCalculations[level.type], isLast)
}
});


}


customElements.define("timing-calculation", TimingCalculation);
30 changes: 29 additions & 1 deletion public/canjs/routing/route-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import {
toSelectedParts
} from "./data-utils.js";

import {getTimingLevels} from "../controls/timeline-configuration/timing-calculation/helpers.js";

const _15DAYS_IN_S = DAY_IN_MS / 1000 * 15;

const booleanParsing = {
Expand Down Expand Up @@ -82,7 +84,29 @@ class RouteData extends ObservableObject {
return getAllTeamData(this.storage)
},
get simplifiedIssueHierarchyPromise(){
return getSimplifiedIssueHierarchy( { jiraHelpers: this.jiraHelpers, isLoggedIn: this.isLoggedInObservable.value })
return getSimplifiedIssueHierarchy( {
jiraHelpers: this.jiraHelpers,
isLoggedIn: this.isLoggedInObservable.value
})
},
simplifiedIssueHierarchy: {
async(resolve){
return this.simplifiedIssueHierarchyPromise;
}
},
get issueTimingCalculations(){
if(!this.simplifiedIssueHierarchy) {
return [];
} else {
const allLevels = getTimingLevels(this.simplifiedIssueHierarchy, this.timingCalculations);
return allLevels.map( level => {
return {
type: level.type,
hierarchyLevel: level.hierarchyLevel,
calculation: level.calculations.find( (level) => level.selected).calculation
}
})
}
},


Expand Down Expand Up @@ -302,6 +326,7 @@ class RouteData extends ObservableObject {
return REPORTS;
}
},

get issueHierarchy(){
return this.derivedIssues && this.derivedIssues.length ?
issueHierarchyFromNormalizedIssues(this.derivedIssues) :
Expand Down Expand Up @@ -427,6 +452,9 @@ class RouteData extends ObservableObject {
}
}




const routeData = new RouteData();
console.log("routeData", routeData);

Expand Down
2 changes: 1 addition & 1 deletion public/stateful-data/jira-data-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const getServerInfo = makeCacheable(({ jiraHelpers, isLoggedIn }) => {
});

export const getSimplifiedIssueHierarchy = makeCacheable(({ jiraHelpers, isLoggedIn }) => {
if (jiraHelpers.hasValidAccessToken()) {
if (isLoggedIn) {
return jiraHelpers.fetchIssueTypes().then(simplifyIssueHierarchy);
} else {
return bitoviTrainingIssueData().then(simplifyIssueHierarchy);
Expand Down
5 changes: 2 additions & 3 deletions public/timeline-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class TimelineReport extends StacheElement {
isLoggedIn:from="this.loginComponent.isLoggedIn"
jiraHelpers:from="this.jiraHelpers"
showSidebarBranding:from="this.showSidebarBranding"
issueTimingCalculations:to="this.issueTimingCalculations"
statuses:to="this.statuses"
goBack:to="this.goBack"
storage:from="this.storage"
Expand Down Expand Up @@ -229,7 +228,7 @@ export class TimelineReport extends StacheElement {
if (this.routeData.primaryIssueType === "Release") {
if (this.routeData.secondaryIssueType) {
const secondary = getIssueHierarchyUnderType(
this.issueTimingCalculations,
this.routeData.issueTimingCalculations,
this.routeData.secondaryIssueType
);
return [
Expand All @@ -238,7 +237,7 @@ export class TimelineReport extends StacheElement {
];
}
} else {
return getIssueHierarchyUnderType(this.issueTimingCalculations, this.routeData.primaryIssueType);
return getIssueHierarchyUnderType(this.routeData.issueTimingCalculations, this.routeData.primaryIssueType);
}
}

Expand Down

0 comments on commit d589345

Please sign in to comment.