diff options
Diffstat (limited to 'perllib/FixMyStreet/DB')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Contact.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Contact.pm | 9 |
2 files changed, 19 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Contact.pm b/perllib/FixMyStreet/DB/Result/Contact.pm index 17620f279..3ce0ec66f 100644 --- a/perllib/FixMyStreet/DB/Result/Contact.pm +++ b/perllib/FixMyStreet/DB/Result/Contact.pm @@ -121,6 +121,16 @@ sub get_metadata_for_input { return \@metadata; } +sub get_metadata_for_storage { + my $self = shift; + my $metadata = $self->get_metadata_for_input; + + # Also ignore any that were only for textual display + my @metadata = grep { ($_->{variable} || '') ne 'false' } @$metadata; + + return \@metadata; +} + sub id_field { my $self = shift; return $self->get_extra_metadata('id_field') || 'fixmystreet_id'; diff --git a/perllib/FixMyStreet/DB/ResultSet/Contact.pm b/perllib/FixMyStreet/DB/ResultSet/Contact.pm index 8ef6d1ac5..7b3258262 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Contact.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Contact.pm @@ -37,4 +37,13 @@ sub summary_count { ); } +sub group_lookup { + my $rs = shift; + map { + my $group = $_->get_extra_metadata('group') || ''; + $group = join(',', ref $group ? @$group : $group); + $_->category => $group + } $rs->all; +} + 1; |