aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App.pm1
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm1
-rw-r--r--perllib/FixMyStreet/Map.pm1
-rw-r--r--perllib/Problems.pm288
-rwxr-xr-xt/Problems.t22
5 files changed, 0 insertions, 313 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index ae4514a0e..3aa81bd2b 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -6,7 +6,6 @@ use Catalyst::Runtime 5.80;
use FixMyStreet;
use FixMyStreet::Cobrand;
use Memcached;
-use Problems;
use mySociety::Email;
use mySociety::EmailUtil;
use mySociety::Random qw(random_bytes);
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 17ebc8b0c..f2bb13ae4 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -2,7 +2,6 @@ package FixMyStreet::App::Controller::Reports;
use Moose;
use namespace::autoclean;
-use Problems;
use POSIX qw(strcoll);
use mySociety::MaPit;
use mySociety::VotingArea;
diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm
index 6a5a82fa9..125aca9e6 100644
--- a/perllib/FixMyStreet/Map.pm
+++ b/perllib/FixMyStreet/Map.pm
@@ -19,7 +19,6 @@ use Module::Pluggable
# Get the list of maps we want and load map classes at compile time
my @ALL_MAP_CLASSES = allowed_maps();
-use Problems;
use mySociety::Config;
use mySociety::Gaze;
use mySociety::Locale;
diff --git a/perllib/Problems.pm b/perllib/Problems.pm
deleted file mode 100644
index 987820d0c..000000000
--- a/perllib/Problems.pm
+++ /dev/null
@@ -1,288 +0,0 @@
-#!/usr/bin/perl
-#
-# Problems.pm:
-# Various problem report database fetching related functions for FixMyStreet.
-#
-# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
-#
-# $Id: Problems.pm,v 1.33 2010-01-20 11:09:45 matthew Exp $
-#
-
-package Problems;
-
-use strict;
-use Encode;
-use Memcached;
-use mySociety::DBHandle qw/dbh select_all/;
-use mySociety::Locale;
-use mySociety::Web qw/ent/;
-use mySociety::MaPit;
-
-my $site_restriction = '';
-my $site_key = 0;
-
-# Admin view functions
-
-=item problem_search SEARCH
-
-Returns all problems containing the search term in their name, email, title,
-detail or council, or whose ID is the search term. Uses any site_restriction
-defined by a cobrand.
-
-=cut
-sub problem_search {
- my ($search) = @_;
- my $search_n = 0;
- $search_n = int($search) if $search =~ /^\d+$/;
- my $problems = select_all("select problem.id, council, category, title, problem.name,
- email, anonymous, cobrand, cobrand_data, created, confirmed, state, service, lastupdate,
- whensent, send_questionnaire from problem, users where problem.user_id = users.id
- and (problem.id=? or email ilike '%'||?||'%' or problem.name ilike '%'||?||'%' or title ilike '%'||?||'%' or
- detail ilike '%'||?||'%' or council like '%'||?||'%' or cobrand_data like '%'||?||'%')
- $site_restriction
- order by (state='hidden'),created", $search_n,
- $search, $search, $search, $search, $search, $search);
- return $problems;
-}
-
-=item update_search SEARCH
-
-Returns all updates containing the search term in their name, email or text, or whose ID
-is the search term. Uses any site_restriction defined by a cobrand.
-
-=cut
-sub update_search {
- my ($search) = @_;
- my $search_n = 0;
- $search_n = int($search) if $search =~ /^\d+$/;
- my $updates = select_all("select comment.*, problem.council, problem.state as problem_state
- from comment, problem, users where problem.id = comment.problem_id and comment.user_id = users.id
- and (comment.id=? or
- problem_id=? or users.email ilike '%'||?||'%' or comment.name ilike '%'||?||'%' or
- comment.text ilike '%'||?||'%' or comment.cobrand_data ilike '%'||?||'%')
- $site_restriction
- order by (comment.state='hidden'),(problem.state='hidden'),created", $search_n, $search_n, $search, $search,
- $search, $search);
- return $updates;
-}
-
-=item update_counts
-
-An array reference of updates grouped by state. Uses any site_restriction defined by a cobrand.
-
-=cut
-
-sub update_counts {
- return dbh()->selectcol_arrayref("select comment.state, count(comment.*) as c from comment, problem
- where problem.id = comment.problem_id
- $site_restriction
- group by comment.state", { Columns => [1,2] });
-}
-
-=item problem_counts
-
-An array reference of problems grouped by state. Uses any site_restriction defined by a cobrand.
-
-=cut
-
-sub problem_counts {
- return dbh()->selectcol_arrayref("select state, count(*) as c from problem
- where id=id $site_restriction
- group by state", { Columns => [1,2] });
-}
-
-=item
-
-An array reference of alerts grouped by state (specific to the cobrand if there is one).
-
-=cut
-
-sub alert_counts {
- my ($cobrand) = @_;
- my $cobrand_clause = '';
- if ($cobrand) {
- $cobrand_clause = " where cobrand = '$cobrand'";
- }
- return dbh()->selectcol_arrayref("select confirmed, count(*) as c
- from alert
- $cobrand_clause
- group by confirmed", { Columns => [1,2] });
-}
-
-=item questionnaire_counts
-
-An array reference of questionnaires. Restricted to questionnaires related to
-problems submitted through the cobrand if a cobrand is specified.
-
-=cut
-sub questionnaire_counts {
- my ($cobrand) = @_;
- my $cobrand_clause = '';
- if ($cobrand) {
- $cobrand_clause = " and cobrand = '$cobrand'";
- }
- my $questionnaires = dbh()->selectcol_arrayref("select (whenanswered is not null), count(questionnaire.*) as c
- from questionnaire, problem
- where problem.id = questionnaire.problem_id
- $cobrand_clause
- group by (whenanswered is not null)", { Columns => [1,2] });
- return $questionnaires;
-}
-
-=item contact_counts COBRAND
-
-An array reference of contacts. Restricted to contacts relevant to
-the cobrand if a cobrand is specified.
-
-=cut
-sub contact_counts {
- my ( $c ) = @_;
- my $contact_restriction = $c->cobrand->contact_restriction;
- my $contacts = dbh()->selectcol_arrayref("select confirmed, count(*) as c from contacts $contact_restriction group by confirmed", { Columns => [1,2] });
- return $contacts;
-}
-
-=item admin_fetch_problem ID
-
-Return an array reference of data relating to a problem, to be used in the admin interface.
-Uses any site_restriction defined by a cobrand.
-
-=cut
-
-sub admin_fetch_problem {
- my ($id) = @_;
- my $problem = dbh()->selectall_arrayref("select problem.*, users.email from problem, users
- where problem.id=? and users.id = problem.user_id
- $site_restriction", { Slice=>{} }, $id);
- return $problem;
-}
-
-=item admin_fetch_update ID
-
-Return an array reference of data relating to an update, to be used in the admin interface.
-Uses any site_restriction defined by a cobrand.
-
-=cut
-sub admin_fetch_update {
- my ($id) = @_;
- my $update = dbh()->selectall_arrayref("select comment.*, problem.council, users.email from comment, problem, users
- where comment.id=?
- and problem.id = comment.problem_id
- and users.id = comment.user_id
- $site_restriction", { Slice=>{} }, $id);
- return $update;
-}
-
-=item timeline_problems
-
-Return a reference to an array of problems suitable for display in the admin timeline.
-Uses any site_restriction defined by a cobrand.
-=cut
-sub timeline_problems {
- my $current_timestamp = current_timestamp();
- my $problems = select_all("select state,problem.id,problem.name,users.email,title,council,category,service,cobrand,cobrand_data,
- extract(epoch from created) as created,
- extract(epoch from confirmed) as confirmed,
- extract(epoch from whensent) as whensent
- from problem, users
- where problem.user_id = users.id
- and (created>=$current_timestamp-'7 days'::interval
- or confirmed>=$current_timestamp-'7 days'::interval
- or whensent>=$current_timestamp-'7 days'::interval)
- $site_restriction");
- return $problems;
-
-}
-
-=item timeline_updates
-
-Return a reference to an array of updates suitable for display in the admin timeline.
-Uses any site_restriction defined by a cobrand.
-
-=cut
-
-sub timeline_updates {
- my $updates = select_all("select comment.*,
- extract(epoch from comment.created) as created,
- users.email,
- problem.council
- from comment, problem, users
- where comment.problem_id = problem.id
- and comment.user_id = users.id
- and comment.state='confirmed'
- and comment.created>=" . current_timestamp() . "-'7 days'::interval
- $site_restriction");
- return $updates;
-}
-
-=item timeline_alerts COBRAND
-
-Return a reference to an array of alerts suitable for display in the admin timeline. Restricted to
-cobranded alerts if a cobrand is specified.
-
-=cut
-sub timeline_alerts {
- my ($cobrand) = @_;
- my $cobrand_clause = '';
- if ($cobrand) {
- $cobrand_clause = " and cobrand = '$cobrand'";
- }
- my $alerts = select_all("select alert.*, users.email, users.name,
- extract(epoch from whensubscribed) as whensubscribed
- from alert, users
- where alert.user_id = users.id
- and whensubscribed>=" . current_timestamp() . "-'7 days'::interval
- and confirmed=1
- $cobrand_clause");
- return $alerts;
-
-}
-
-=item timeline_deleted_alerts COBRAND
-
-Return a reference to an array of deleted alerts suitable for display in the admin timeline. Restricted to
-cobranded alerts if a cobrand is specified.
-
-=cut
-sub timeline_deleted_alerts {
- my ($cobrand) = @_;
- my $cobrand_clause = '';
- if ($cobrand) {
- $cobrand_clause = " and cobrand = '$cobrand'";
- }
-
- my $alerts = select_all("select *,
- extract(epoch from whensubscribed) as whensubscribed,
- extract(epoch from whendisabled) as whendisabled
- from alert where whendisabled>=" . current_timestamp() . "-'7 days'::interval
- $cobrand_clause");
- return $alerts;
-
-}
-
-=item timeline_questionnaires
-
-Return a reference to an array of questionnaires suitable for display in the admin timeline. Restricted to
-questionnaires for cobranded problems if a cobrand is specified.
-
-=cut
-
-sub timeline_questionnaires {
- my ($cobrand) = @_;
- my $cobrand_clause = '';
- if ($cobrand) {
- $cobrand_clause = " and cobrand = '$cobrand'";
- }
- my $current_timestamp = current_timestamp();
- my $questionnaire = select_all("select questionnaire.*,
- extract(epoch from questionnaire.whensent) as whensent,
- extract(epoch from questionnaire.whenanswered) as whenanswered
- from questionnaire, problem
- where questionnaire.problem_id = problem.id
- and (questionnaire.whensent>=$current_timestamp-'7 days'::interval
- or questionnaire.whenanswered>=$current_timestamp-'7 days'::interval)
- $cobrand_clause");
-}
-
-1;
diff --git a/t/Problems.t b/t/Problems.t
deleted file mode 100755
index 40b3b810c..000000000
--- a/t/Problems.t
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/perl -w
-#
-# Problem.t:
-# Tests for the Problem functions
-#
-# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
-# Email: louise@mysociety.org; WWW: http://www.mysociety.org/
-#
-# $Id: Problems.t,v 1.3 2009-11-12 14:05:18 louise Exp $
-#
-
-use strict;
-use warnings;
-use Test::More tests => 1;
-use Test::Exception;
-
-use FindBin;
-use lib "$FindBin::Bin";
-use lib "$FindBin::Bin/../perllib";
-use lib "$FindBin::Bin/../commonlib/perllib";
-BEGIN { use_ok( 'Problems' ); }
-