Fixes bug in ExpireIncompleteSurveyResponses

Use a left outer join on userProfileData so that the workflow processes
responses for users that have been deleted
This commit is contained in:
Patrick Donelan 2009-10-20 16:50:00 +11:00
parent c8542cc5d0
commit e4b18757d8
3 changed files with 11 additions and 3 deletions

View file

@ -28,6 +28,7 @@
- fixed #11137: Customers see failed orders - fixed #11137: Customers see failed orders
- fixed #11156: Syndicated Content doesn't show all headlines in feed - fixed #11156: Syndicated Content doesn't show all headlines in feed
- fixed #11138: RichEdit, upload image does not commit a version tag - fixed #11138: RichEdit, upload image does not commit a version tag
- fixed ExpireIncompleteSurveyResponses Workflow: process responses for deleted users
7.8.1 7.8.1
- mark $session->datetime->time as deprecated and remove its use from core code - mark $session->datetime->time as deprecated and remove its use from core code

View file

@ -159,6 +159,7 @@ Factored out into a separate subroutine for the sake of testability.
sub getSql { sub getSql {
# Use a left outer join on userProfileData so that we still get back responses for users that have been deleted
return <<END_SQL; return <<END_SQL;
select select
r.Survey_responseId, r.username, r.userId, r.startDate, r.Survey_responseId, r.username, r.userId, r.startDate,
@ -166,7 +167,7 @@ select
s.timeLimit, s.doAfterTimeLimit, s.timeLimit, s.doAfterTimeLimit,
ad.title, ad.url ad.title, ad.url
from from
Survey_response r, Survey s, assetData ad, userProfileData upd Survey_response r left outer join userProfileData upd on r.userId = upd.userId, Survey s, assetData ad
where where
r.isComplete = 0 r.isComplete = 0
and s.timeLimit > 0 and s.timeLimit > 0
@ -175,7 +176,6 @@ where
and ad.assetId = s.assetId and ad.assetId = s.assetId
and ad.revisionDate = s.revisionDate and ad.revisionDate = s.revisionDate
and s.revisionDate = r.revisionDate and s.revisionDate = r.revisionDate
and upd.userId = r.userId
END_SQL END_SQL
} }

View file

@ -13,7 +13,7 @@ my $session = WebGUI::Test->session;
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Tests # Tests
plan tests => 25; plan tests => 26;
use_ok('WebGUI::Workflow::Activity::ExpireIncompleteSurveyResponses'); use_ok('WebGUI::Workflow::Activity::ExpireIncompleteSurveyResponses');
@ -127,6 +127,13 @@ $session->db->write('update Survey_response set endDate = 0, isComplete = 0 wher
# Make sure SQL only returns 1 incomplete response # Make sure SQL only returns 1 incomplete response
is( scalar $session->db->buildArray($SQL), 1, 'Make sure SQL only returns 1 incomplete response'); is( scalar $session->db->buildArray($SQL), 1, 'Make sure SQL only returns 1 incomplete response');
##
# Make sure workflow handles responses for deleted users
#
$session->db->write('update Survey_response set userId = ? where Survey_responseId = ?', ['not-a-user-id', $responseId]);
is( scalar $session->db->buildArray($SQL), 1, 'Still returns 1 row, even though user does not exist (sql left outer join)');
$session->db->write('update Survey_response set userId = ? where Survey_responseId = ?', [$user->getId, $responseId]);
## ##
# Delete Expired # Delete Expired
## ##