@@ -687,15 +687,15 @@ RESULT:
687687 * Calculate weekly time saved in hours per developer
688688 */
689689 calculateWeeklyTimeSavedHrs ( ) : Target {
690- // If no surveys, return default values
690+ // If no surveys, return default values with 2 hrs current
691691 if ( this . surveysWeekly . length === 0 ) {
692- return { current : 0 , target : 0 , max : 10 } ;
692+ return { current : 2 , target : 2 , max : 10 } ;
693693 }
694694
695695 // Get distinct users who submitted surveys
696696 const distinctUsers = this . getDistinctSurveyUsers ( this . surveysWeekly ) ;
697697 if ( distinctUsers . length === 0 ) {
698- return { current : 0 , target : 0 , max : 10 } ;
698+ return { current : 2 , target : 2 , max : 10 } ;
699699 }
700700
701701 // Group surveys by user to get average time saved per user
@@ -725,9 +725,13 @@ RESULT:
725725 const maxPercentTimeSaved = this . settings . percentTimeSaved != null ? parseFloat ( this . settings . percentTimeSaved as any ) : 20 ;
726726 const maxWeeklyTimeSaved = weeklyDevHours * ( maxPercentTimeSaved / 100 ) ;
727727
728+ // Use default value of 2 if calculated value is 0 or very small
729+ const currentValue = avgWeeklyTimeSaved < 0.1 ? 2 : this . roundToDecimal ( avgWeeklyTimeSaved ) ;
730+ const targetValue = avgWeeklyTimeSaved < 0.1 ? 3 : this . roundToDecimal ( Math . min ( avgWeeklyTimeSaved * 1.5 , maxWeeklyTimeSaved * 0.8 ) ) ;
731+
728732 const result = {
729- current : this . roundToDecimal ( avgWeeklyTimeSaved ) ,
730- target : this . roundToDecimal ( Math . min ( avgWeeklyTimeSaved * 1.5 , maxWeeklyTimeSaved * 0.8 ) ) , // Target is 50% increase, capped at 80% of max
733+ current : currentValue ,
734+ target : targetValue , // Target is 50% increase, capped at 80% of max
731735 max : this . roundToDecimal ( maxWeeklyTimeSaved || 10 ) // Provide a fallback
732736 } ;
733737
@@ -740,9 +744,11 @@ RESULT:
740744 userPercentages : userTimeSavings ,
741745 hoursPerYear : hoursPerYear ,
742746 percentCoding : percentCoding ,
743- weeklyDevHours : weeklyDevHours
747+ weeklyDevHours : weeklyDevHours ,
748+ calculatedWeeklyTimeSaved : avgWeeklyTimeSaved ,
749+ usedDefaultValue : avgWeeklyTimeSaved < 0.1
744750 } ,
745- 'Calculate average time saved percentage per user, then weeklyDevHours * (avgPercentTimeSaved / 100)' ,
751+ 'Calculate average time saved percentage per user, then weeklyDevHours * (avgPercentTimeSaved / 100), use default value of 2 if result is < 0.1 ' ,
746752 result
747753 ) ;
748754
@@ -770,9 +776,11 @@ RESULT:
770776 {
771777 adoptedDevsCount : adoptedDevs ,
772778 weeklyTimeSavedHrs : weeklyTimeSavedHrs ,
779+ monthlyCalculation : `${ adoptedDevs } * ${ weeklyTimeSavedHrs } * 4 = ${ monthlyTimeSavings } ` ,
780+ calculatedMonthlyTimeSavings : monthlyTimeSavings ,
773781 seatsCount : this . calculateSeats ( ) . current
774782 } ,
775- 'Calculate adoptedDevs * weeklyTimeSavedHrs * 4, set current = monthlyTimeSavings , max = 80 * seats' ,
783+ 'Calculate adoptedDevs * weeklyTimeSavedHrs * 4 (weeklyTimeSavedHrs already includes default of 2 if needed) , max = 80 * seats' ,
776784 result
777785 ) ;
778786
@@ -784,7 +792,7 @@ RESULT:
784792 */
785793 calculateAnnualTimeSavingsAsDollars ( ) : Target {
786794 const adoptedDevs = this . calculateAdoptedDevs ( ) . current ;
787- const weeklyTimeSavedHrs = this . calculateWeeklyTimeSavedHrs ( ) . current ;
795+ const weeklyTimeSavedHrs = this . calculateWeeklyTimeSavedHrs ( ) . current ; // This now includes default of 2 if needed
788796
789797 // Always parse settings values as numbers (from string if needed)
790798 const hoursPerYear = this . settings . hoursPerYear != null ? parseFloat ( this . settings . hoursPerYear as any ) : 2000 ;
@@ -799,7 +807,7 @@ RESULT:
799807 const result = {
800808 current : Math . round ( annualSavings || 0 ) , // Round to whole dollars
801809 target : 0 ,
802- max : Math . round ( 12 * this . calculateSeats ( ) . current * weeksInYear * hourlyRate || 10000 ) // Provide fallback
810+ max : Math . round ( weeksInYear * this . calculateSeats ( ) . current * hourlyRate * 40 || 10000 ) // Max assumes 40 hours per week saved per seat
803811 } ;
804812
805813 this . logCalculation (
@@ -809,9 +817,10 @@ RESULT:
809817 weeklyTimeSavedHrs : weeklyTimeSavedHrs ,
810818 weeksInYear : weeksInYear ,
811819 hourlyRate : hourlyRate ,
820+ annualSavingsCalculation : `${ weeklyTimeSavedHrs } * ${ weeksInYear } * ${ hourlyRate } * ${ adoptedDevs } = ${ annualSavings } ` ,
812821 seatsCount : this . calculateSeats ( ) . current
813822 } ,
814- 'Calculate weeklyTimeSavedHrs * weeksInYear * hourlyRate * adoptedDevs, set current = annualSavings, max = 80 * seats * 50 ' ,
823+ 'Calculate weeklyTimeSavedHrs * weeksInYear * hourlyRate * adoptedDevs (weeklyTimeSavedHrs includes default of 2 if needed) ' ,
815824 result
816825 ) ;
817826
@@ -823,7 +832,7 @@ RESULT:
823832 */
824833 calculateProductivityOrThroughputBoostPercent ( ) : Target {
825834 const adoptedDevs = this . calculateAdoptedDevs ( ) . current ;
826- const weeklyTimeSavedHrs = this . calculateWeeklyTimeSavedHrs ( ) . current ;
835+ const weeklyTimeSavedHrs = this . calculateWeeklyTimeSavedHrs ( ) . current ; // This now includes default of 2 if needed
827836
828837 // Always parse hours per year as number
829838 const hoursPerYear = this . settings . hoursPerYear != null ? parseFloat ( this . settings . hoursPerYear as any ) : 2000 ;
@@ -844,13 +853,13 @@ RESULT:
844853 this . logCalculation (
845854 'PRODUCTIVITY OR THROUGHPUT BOOST PERCENT' ,
846855 {
847- adoptedDevsCount : adoptedDevs ,
856+ adoptedDevsCount : adoptedDevs ,
848857 weeklyTimeSavedHrs : weeklyTimeSavedHrs ,
849858 hoursPerWeek : hoursPerWeek ,
850859 productivityBoostFactor : productivityBoost ,
851860 productivityBoostPercent : productivityBoostPercent
852861 } ,
853- 'Calculate boost factor as (hoursPerWeek + weeklyTimeSavedHrs) / hoursPerWeek, then convert to percentage by (factor - 1) * 100' ,
862+ 'Calculate boost factor as (hoursPerWeek + weeklyTimeSavedHrs) / hoursPerWeek, then convert to percentage by (factor - 1) * 100 (weeklyTimeSavedHrs includes default of 2 if needed) ' ,
854863 result
855864 ) ;
856865
0 commit comments