diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-08-15 17:35:53 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-08-17 10:58:30 +0100 |
commit | 1bdef6cf43c1c6bd8f58a2533468db09b098213c (patch) | |
tree | 4f76b1cb8e2bd14018c97db4b951997b4abfc318 /bin | |
parent | 60b941bc7868c4b0a829f7d497262015d6ab69c4 (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')
-rwxr-xr-x | bin/one-off-update-duplicates | 20 |
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); +} |