-
-
Notifications
You must be signed in to change notification settings - Fork 9
Diagnostics-for-account-and-installations #242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
febd03a
added /diagnostics page for installation / org list visibility
MattG57 d25d64a
replaced any : types everywhere
MattG57 9f21f23
removed unused type
MattG57 602d9ff
Merge value modeling improvements from targeting-bugfixes while prese…
MattG57 0a73427
Updated targeting to fix bugs, remove any : types and default impact …
MattG57 f48bb22
Implement type-safe parsing for numeric values in TargetCalculationSe…
MattG57 e8486e5
Enhance type safety by updating recalculateTargets response handling …
MattG57 51b7898
Refactor TargetsCalculationResponse to use CalculationLog type for logs
MattG57 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -687,22 +687,23 @@ | |||||||
| * Calculate weekly time saved in hours per developer | ||||||||
| */ | ||||||||
| calculateWeeklyTimeSavedHrs(): Target { | ||||||||
| // If no surveys, return default values | ||||||||
| // If no surveys, return default values with 2 hrs current | ||||||||
| if (this.surveysWeekly.length === 0) { | ||||||||
| return { current: 0, target: 0, max: 10 }; | ||||||||
| return { current: 2, target: 2, max: 10 }; | ||||||||
| } | ||||||||
|
|
||||||||
| // Get distinct users who submitted surveys | ||||||||
| const distinctUsers = this.getDistinctSurveyUsers(this.surveysWeekly); | ||||||||
| if (distinctUsers.length === 0) { | ||||||||
| return { current: 0, target: 0, max: 10 }; | ||||||||
| return { current: 2, target: 2, max: 10 }; | ||||||||
| } | ||||||||
|
|
||||||||
| // Group surveys by user to get average time saved per user | ||||||||
| const userTimeSavings = distinctUsers.map(userId => { | ||||||||
| const userSurveys = this.surveysWeekly.filter(survey => survey.userId === userId); | ||||||||
| const totalPercent = userSurveys.reduce((sum, survey) => { | ||||||||
| const percentTimeSaved = typeof survey.percentTimeSaved === 'number' ? survey.percentTimeSaved : 0; | ||||||||
| // Always parse percentTimeSaved as float | ||||||||
| const percentTimeSaved = survey.percentTimeSaved != null ? parseFloat(survey.percentTimeSaved as any) : 0; | ||||||||
|
||||||||
| return sum + percentTimeSaved; | ||||||||
| }, 0); | ||||||||
| return totalPercent / userSurveys.length; // Average percent time saved per user | ||||||||
|
|
@@ -711,22 +712,26 @@ | |||||||
| // Average across all users | ||||||||
| const avgPercentTimeSaved = userTimeSavings.reduce((sum, percent) => sum + percent, 0) / userTimeSavings.length; | ||||||||
|
|
||||||||
| // Convert settings values to numbers | ||||||||
| const hoursPerYear = typeof this.settings.hoursPerYear === 'number' ? this.settings.hoursPerYear : 2000; | ||||||||
| const percentCoding = typeof this.settings.percentCoding === 'number' ? this.settings.percentCoding : 50; | ||||||||
| // Convert settings values to numbers (parse from string if needed) | ||||||||
| const hoursPerYear = this.settings.hoursPerYear != null ? parseFloat(this.settings.hoursPerYear as any) : 2000; | ||||||||
|
||||||||
| const percentCoding = this.settings.percentCoding != null ? parseFloat(this.settings.percentCoding as any) : 50; | ||||||||
|
||||||||
|
|
||||||||
| // Calculate weekly hours saved based on settings and average percent | ||||||||
| const weeklyHours = hoursPerYear / 50; // Assuming 50 working weeks | ||||||||
| const weeklyDevHours = weeklyHours * (percentCoding / 100); | ||||||||
| const avgWeeklyTimeSaved = weeklyDevHours * (avgPercentTimeSaved / 100); | ||||||||
|
|
||||||||
| // Calculate max based on settings | ||||||||
| const maxPercentTimeSaved = typeof this.settings.percentTimeSaved === 'number' ? this.settings.percentTimeSaved : 20; | ||||||||
| const maxPercentTimeSaved = this.settings.percentTimeSaved != null ? parseFloat(this.settings.percentTimeSaved as any) : 20; | ||||||||
|
||||||||
| const maxWeeklyTimeSaved = weeklyDevHours * (maxPercentTimeSaved / 100); | ||||||||
|
|
||||||||
| // Use default value of 2 if calculated value is 0 or very small | ||||||||
| const currentValue = avgWeeklyTimeSaved < 0.1 ? 2 : this.roundToDecimal(avgWeeklyTimeSaved); | ||||||||
| const targetValue = avgWeeklyTimeSaved < 0.1 ? 3 : this.roundToDecimal(Math.min(avgWeeklyTimeSaved * 1.5, maxWeeklyTimeSaved * 0.8)); | ||||||||
|
||||||||
| const targetValue = avgWeeklyTimeSaved < 0.1 ? 3 : this.roundToDecimal(Math.min(avgWeeklyTimeSaved * 1.5, maxWeeklyTimeSaved * 0.8)); | |
| const currentValue = avgWeeklyTimeSaved < MIN_WEEKLY_TIME_SAVED_THRESHOLD ? DEFAULT_WEEKLY_TIME_SAVED : this.roundToDecimal(avgWeeklyTimeSaved); | |
| const targetValue = avgWeeklyTimeSaved < MIN_WEEKLY_TIME_SAVED_THRESHOLD ? DEFAULT_TARGET_WEEKLY_TIME_SAVED : this.roundToDecimal(Math.min(avgWeeklyTimeSaved * 1.5, maxWeeklyTimeSaved * 0.8)); |
Fixed
Show fixed
Hide fixed
Fixed
Show fixed
Hide fixed
Fixed
Show fixed
Hide fixed
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 2 for default hours appears multiple times in this method. Consider defining this as a named constant at the class level to improve maintainability.
Note: See the diff below for a potential fix: