[MKDoc-commit] Added code to only include centres in the summary
email if they have an
sam at mkdoc.demon.co.uk
sam at mkdoc.demon.co.uk
Fri Mar 24 22:46:09 GMT 2006
Log Message:
-----------
Added code to only include centres in the summary email if they have an editor assigned who is in the Portal or Portal Administrator group.
Tags:
----
mkdoc-1-6
Modified Files:
--------------
mkd/tools:
ufi_survey_mailer.pl
-------------- next part --------------
Index: ufi_survey_mailer.pl
===================================================================
RCS file: /var/spool/cvs/mkd/tools/Attic/ufi_survey_mailer.pl,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -Ltools/ufi_survey_mailer.pl -Ltools/ufi_survey_mailer.pl -u -r1.1.2.5 -r1.1.2.6
--- tools/ufi_survey_mailer.pl
+++ tools/ufi_survey_mailer.pl
@@ -130,8 +130,17 @@
my $survey = shift;
print "Sending summary for survey ending $survey->{end_date} to:\n\n";
+ # FIX - replace this with a straight count of Centre_Details after
+ # testing is over
my ($total)
- = $dbh->selectrow_array('SELECT COUNT(*) FROM Centre_Details');
+ = $dbh->selectrow_array(
+ 'SELECT COUNT(DISTINCT Centre_ID)
+ FROM Editor_Centre
+ LEFT JOIN Editor_Grp USING (Editor_ID)
+ LEFT JOIN Grp ON (Editor_Grp.Grp_ID = Grp.ID)
+ WHERE Grp.Name IN (?,?)',
+ undef, 'Portal', 'Portal Administrators');
+
my ($submitted)
= $dbh->selectrow_array('SELECT COUNT(*) FROM MI_Survey
WHERE MI_Survey_Period_ID = ?', undef,
@@ -142,15 +151,19 @@
'SELECT Centre_ID FROM MI_Survey
WHERE MI_Survey_Period_ID = ?', undef, $survey->{id});
- # find editors of missing ones
+ # find missing centres (FIX - remove joins after testing is over)
my $results = $dbh->selectall_arrayref(
- 'SELECT Centre_ID, Centre_Name
- FROM Centre_Details ' .
- (@$exists ?
- (' WHERE Centre_ID NOT IN (' . join(',', ('?') x @$exists) . ')') :
+ 'SELECT DISTINCT cd.Centre_ID, cd.Centre_Name
+ FROM Centre_Details cd
+ LEFT JOIN Editor_Centre USING (Centre_ID)
+ LEFT JOIN Editor_Grp USING (Editor_ID)
+ LEFT JOIN Grp ON (Editor_Grp.Grp_ID = Grp.ID)
+ WHERE Grp.Name IN (?,?) ' .
+ (@$exists ?
+ (' AND cd.Centre_ID NOT IN (' . join(',', ('?') x @$exists) . ')') :
'') .
- ' ORDER BY Centre_Name',
- undef, @$exists);
+ ' ORDER BY cd.Centre_Name',
+ undef, 'Portal', 'Portal Administrators', @$exists);
my @missing = map { { id => $_->[0], name => $_->[1] } } @$results;
UFI::MI::SurveySummary->new(total => $total,
More information about the MKDoc-commit
mailing list