aboutsummaryrefslogtreecommitdiffstats
path: root/bin/one-off-update-duplicates
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-08-15 17:35:53 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-08-17 10:58:30 +0100
commit1bdef6cf43c1c6bd8f58a2533468db09b098213c (patch)
tree4f76b1cb8e2bd14018c97db4b951997b4abfc318 /bin/one-off-update-duplicates
parent60b941bc7868c4b0a829f7d497262015d6ab69c4 (diff)
Store duplicate reverse lookups upon dupe setting.
This avoids the need to search the whole table to find a report's duplicates. And is easier than constructing an index or upgrading PostgreSQL.
Diffstat (limited to 'bin/one-off-update-duplicates')
-rwxr-xr-xbin/one-off-update-duplicates20
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/one-off-update-duplicates b/bin/one-off-update-duplicates
new file mode 100755
index 000000000..7bbf0251f
--- /dev/null
+++ b/bin/one-off-update-duplicates
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+BEGIN {
+ use File::Basename qw(dirname);
+ use File::Spec;
+ my $d = dirname(File::Spec->rel2abs($0));
+ require "$d/../setenv.pl";
+}
+
+use FixMyStreet::DB;
+
+my $rs = FixMyStreet::DB->resultset("Problem")->search({ extra => => { like => "%duplicate_of%" } });
+while (my $row = $rs->next) {
+ my $duplicate_of = $row->get_extra_metadata('duplicate_of');
+ next unless $duplicate_of;
+ $row->set_duplicate_of($duplicate_of);
+}