aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Script
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/Script')
-rw-r--r--perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm35
-rw-r--r--perllib/FixMyStreet/Script/Reports.pm4
2 files changed, 27 insertions, 12 deletions
diff --git a/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm b/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm
index 5d1d45379..31876d83d 100644
--- a/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm
+++ b/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm
@@ -14,10 +14,6 @@ use FixMyStreet::Email;
my $opts = {
commit => 0,
- body => '2237',
- cobrand => 'oxfordshire',
- closure_cutoff => "2015-01-01 00:00:00",
- email_cutoff => "2016-01-01 00:00:00",
};
sub query {
@@ -84,11 +80,7 @@ sub archive {
});
printf("Closing %d old reports, without sending emails: ", $problems_to_close->count);
-
- if ( $opts->{commit} ) {
- $problems_to_close->update({ state => 'closed', send_questionnaire => 0 });
- }
-
+ close_problems($problems_to_close);
printf("done.\n")
}
@@ -132,10 +124,31 @@ sub send_email_and_close {
unless ( $email_error ) {
printf("done.\n Closing reports: ");
-
- $problems->update({ state => 'closed', send_questionnaire => 0 });
+ close_problems($problems);
printf("done.\n");
} else {
printf("error! Not closing reports for this user.\n")
}
}
+
+sub close_problems {
+ return unless $opts->{commit};
+
+ my $problems = shift;
+ while (my $problem = $problems->next) {
+ my $timestamp = \'current_timestamp';
+ $problem->add_to_comments( {
+ text => '',
+ created => $timestamp,
+ confirmed => $timestamp,
+ user_id => $opts->{user},
+ name => _('an administrator'),
+ mark_fixed => 0,
+ anonymous => 0,
+ state => 'confirmed',
+ problem_state => 'closed',
+ extra => { is_superuser => 1 },
+ } );
+ $problem->update({ state => 'closed', send_questionnaire => 0 });
+ }
+}
diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm
index be3c4c69a..b8c3d6d0d 100644
--- a/perllib/FixMyStreet/Script/Reports.pm
+++ b/perllib/FixMyStreet/Script/Reports.pm
@@ -29,7 +29,7 @@ sub send(;$) {
my $site = $site_override || CronFns::site($base_url);
my $states = [ FixMyStreet::DB::Result::Problem::open_states() ];
- $states = [ 'unconfirmed', 'confirmed', 'in progress', 'planned', 'closed', 'investigating' ] if $site eq 'zurich';
+ $states = [ 'submitted', 'confirmed', 'in progress', 'feedback pending', 'external', 'wish' ] if $site eq 'zurich';
my $unsent = $rs->search( {
state => $states,
whensent => undef,
@@ -88,6 +88,8 @@ sub send(;$) {
if ($row->photo) {
$h{has_photo} = _("This web page also contains a photo of the problem, provided by the user.") . "\n\n";
$h{image_url} = $email_base_url . $row->photos->[0]->{url_full};
+ my @all_images = map { $email_base_url . $_->{url_full} } @{ $row->photos };
+ $h{all_image_urls} = \@all_images;
} else {
$h{has_photo} = '';
$h{image_url} = '';