fix(tasks-controller): cap progress calculation at 100% and synchronize complete_ratio
- Updated progress calculation to ensure it does not exceed 100% when time-based progress is enabled. - Set complete_ratio to match the calculated progress, improving accuracy in task completion representation. - Simplified comments for clarity regarding progress defaults and calculations.
This commit is contained in:
@@ -52,15 +52,17 @@ export default class TasksControllerBase extends WorklenzControllerBase {
|
||||
}
|
||||
// For tasks with no subtasks and no manual progress
|
||||
else {
|
||||
// Only calculate time-based progress if time-based calculation is enabled for the project
|
||||
// Only calculate progress based on time if time-based progress is enabled for the project
|
||||
if (task.project_use_time_progress && task.total_minutes_spent && task.total_minutes) {
|
||||
task.progress = ~~(task.total_minutes_spent / task.total_minutes * 100);
|
||||
task.complete_ratio = task.progress;
|
||||
// Cap the progress at 100% to prevent showing more than 100% progress
|
||||
task.progress = Math.min(~~(task.total_minutes_spent / task.total_minutes * 100), 100);
|
||||
} else {
|
||||
// Default to 0% progress for incomplete tasks when time-based calculation is not enabled
|
||||
// Default to 0% progress when time-based calculation is not enabled
|
||||
task.progress = 0;
|
||||
task.complete_ratio = 0;
|
||||
}
|
||||
|
||||
// Set complete_ratio to match progress
|
||||
task.complete_ratio = task.progress;
|
||||
}
|
||||
|
||||
// Ensure numeric values
|
||||
|
||||
Reference in New Issue
Block a user