Associated with r2980: force PM assets to recalculate project completion

percentages in the upgrade script.
This commit is contained in:
Drake 2006-10-06 23:45:26 +00:00
parent 30a47092be
commit 38fdcf335f
2 changed files with 17 additions and 13 deletions

View file

@ -17,22 +17,26 @@ use WebGUI::Session;
my $toVersion = "7.0.10"; # make this match what version you're going to
my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
recalculateProjectCompletion($session);
finish($session); # this line required
##-------------------------------------------------
#sub exampleFunction {
# my $session = shift;
# print "\tWe're doing some stuff here that you should know about.\n" unless ($quiet);
# # and here's our code
#}
sub recalculateProjectCompletion {
my $session = shift;
print "\tForcing project completion recalculation.\n" unless $quiet;
my @assetIds = $session->db->buildArray("SELECT DISTINCT assetId FROM PM_wobject", []);
foreach my $assetId (@assetIds) {
my $pm = WebGUI::Asset->newByDynamicClass($session, $assetId);
my @projectIds = $session->db->buildArray("SELECT projectId FROM PM_project WHERE assetId = ?", [$assetId]);
foreach my $project (@projectIds) {
$pm->updateProject($project);
}
}
}
# ---- DO NOT EDIT BELOW THIS LINE ----

View file

@ -243,7 +243,7 @@ sub updateProjectTask {
}
$self->setCollateral("PM_task","taskId", { taskId=>$taskId, duration=>$task->{duration}, percentComplete=>$task->{percentComplete} });
$self->_updateProject($projectId);
$self->updateProject($projectId);
return 1;
}
@ -271,7 +271,7 @@ sub _userCanManageProjectList {
}
#-------------------------------------------------------------------
sub _updateProject {
sub updateProject {
my $self = shift;
my ($session,$privilege,$form,$db,$dt,$i18n,$user) = $self->setSessionVars;
my $projectId= $_[0];
@ -1071,7 +1071,7 @@ sub www_editTaskSave {
$self->reorderCollateral("PM_task","taskId","projectId",$projectId);
}
$self->_updateProject($projectId);
$self->updateProject($projectId);
$self->_clobberImproperDependants($projectId);
$self->_updateDependantDates($projectId);
@ -1179,7 +1179,7 @@ sub www_saveExistingTasks {
$self->setCollateral("PM_task","taskId",$props,1,0,"projectId",$projectId);
}
$self->_updateProject($projectId);
$self->updateProject($projectId);
$self->_updateDependantDates($projectId);
return $self->www_drawGanttChart();
}