<commit_before>package FixMyStreet::App::Controller::Alert;
use Moose;
use namespace::autoclean;

BEGIN { extends 'Catalyst::Controller'; }

use mySociety::EmailUtil qw(is_valid_email);

=head1 NAME

FixMyStreet::App::Controller::Alert - Catalyst Controller

=head1 DESCRIPTION

Catalyst Controller.

=head1 METHODS

=cut

=head2 alert

Show the alerts page

=cut

sub index : Path('') : Args(0) {
    my ( $self, $c ) = @_;

    $c->stash->{cobrand_form_elements} = $c->cobrand->form_elements('alerts');

    unless ( $c->req->referer && $c->req->referer =~ /fixmystreet\.com/ ) {
        $c->stash->{photos} = $c->cobrand->recent_photos(10);
    }
}

sub list : Path('list') : Args(0) {
    my ( $self, $c ) = @_;

    $c->stash->{rznvy}         = $c->req->param('rznvy');
    $c->stash->{selected_feed} = $c->req->param('feed');

    if ( $c->user ) {
        $c->stash->{rznvy} ||= $c->user->email;
    }

 #    my ($q, @errors) = @_;
 #    my @vars = qw(pc rznvy lat lon);
 #    my %input = map { $_ => scalar $q->param($_) } @vars;
 #    my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } @vars;
 #
 # Try to create a location for whatever we have
    unless ( $c->forward('/location/determine_location_from_coords')
        || $c->forward('/location/determine_location_from_pc') )
    {

        if ( $c->stash->{possible_location_matches} ) {
            $c->stash->{choose_target_uri} = $c->uri_for('/alert/list');
            $c->detach('choose');
        }

        $c->go('index') if $c->stash->{location_error};
    }

    $c->log->debug($_)
      for ( $c->stash->{pc}, $c->stash->{latitude}, $c->stash->{longitude} );

    $c->forward('prettify_pc');

    # truncate the lat,lon for nicer urls
    ( $c->stash->{latitude}, $c->stash->{longitude} ) =
      map { Utils::truncate_coordinate($_) }
      ( $c->stash->{latitude}, $c->stash->{longitude} );
    $c->log->debug($_)
      for ( $c->stash->{pc}, $c->stash->{latitude}, $c->stash->{longitude} );

#
#    my $errors = '';
#    $errors = '<ul class="error"><li>' . join('</li><li>', @errors) . '</li></ul>' if @errors;
#
    $c->stash->{council_check_action} = 'alert';
    unless ( $c->forward('/council/load_and_check_councils_and_wards') ) {
        $c->go('index');
    }

    ( $c->stash->{options}, $c->stash->{reported_to_options} ) =
      $c->cobrand->council_rss_alert_options( $c->stash->{all_councils} );

    my $dist =
      mySociety::Gaze::get_radius_containing_population( $c->stash->{latitude},
        $c->stash->{longitude}, 200000 );
    $dist                          = int( $dist * 10 + 0.5 );
    $dist                          = $dist / 10.0;
    $c->stash->{population_radius} = $dist;


    $c->stash->{photos} = $c->cobrand->recent_photos(
        5,
        $c->stash->{latitude},
        $c->stash->{longitude}, $dist
    );

    $c->stash->{cobrand_form_elements} = $c->cobrand->form_elements('alerts');
#
#    my $checked = '';
#    $checked = ' checked' if $q->param('feed') && $q->param('feed') eq "local:$lat:$lon";
#    my $cobrand_form_elements = Cobrand::form_elements($cobrand, 'alerts', $q);
#    my $pics = Cobrand::recent_photos($cobrand, 5, $lat, $lon, $dist);
#    $pics = '<div id="alert_photos">' . $q->h2(_('Photos of recent nearby reports')) . $pics . '</div>' if $pics;

    #    my $form_action = Cobrand::url($cobrand, '/alert', $q);
    #$cobrand_form_elements
    #$pics
    #
    #EOF
    #    $out .= $errors;
    #    $out .= <<EOF;
    $c->stash->{rss_feed_id} =
      sprintf( 'local:%s:%s', $c->stash->{latitude}, $c->stash->{longitude} );

    my $rss_feed;
    if ( $c->stash->{pretty_pc_text} ) {
        $rss_feed =
          $c->cobrand->uri( "/rss/pc/" . $c->stash->{pretty_pc_text},
            $c->fake_q );
    }
    else {
        $rss_feed = $c->cobrand->uri(
            sprintf( "/rss/l/%s,%s",
                $c->stash->{latitude},
                $c->stash->{longitude} ),
            $c->fake_q
        );
    }

    $c->stash->{rss_feed_uri} = $rss_feed;

#    my $default_link = Cobrand::url($cobrand, "/alert?type=local;feed=local:$lat:$lon", $q);
<commit_msg>removed old commented out code<commit_after>package FixMyStreet::App::Controller::Alert;
use Moose;
use namespace::autoclean;

BEGIN { extends 'Catalyst::Controller'; }

use mySociety::EmailUtil qw(is_valid_email);

=head1 NAME

FixMyStreet::App::Controller::Alert - Catalyst Controller

=head1 DESCRIPTION

Catalyst Controller.

=head1 METHODS

=cut

=head2 alert

Show the alerts page

=cut

sub index : Path('') : Args(0) {
    my ( $self, $c ) = @_;

    $c->stash->{cobrand_form_elements} = $c->cobrand->form_elements('alerts');

    unless ( $c->req->referer && $c->req->referer =~ /fixmystreet\.com/ ) {
        $c->stash->{photos} = $c->cobrand->recent_photos(10);
    }
}

sub list : Path('list') : Args(0) {
    my ( $self, $c ) = @_;

    $c->stash->{rznvy}         = $c->req->param('rznvy');
    $c->stash->{selected_feed} = $c->req->param('feed');

    if ( $c->user ) {
        $c->stash->{rznvy} ||= $c->user->email;
    }

    # Try to create a location for whatever we have
    unless ( $c->forward('/location/determine_location_from_coords')
        || $c->forward('/location/determine_location_from_pc') )
    {

        if ( $c->stash->{possible_location_matches} ) {
            $c->stash->{choose_target_uri} = $c->uri_for('/alert/list');
            $c->detach('choose');
        }

        $c->go('index') if $c->stash->{location_error};
    }

    $c->log->debug($_)
      for ( $c->stash->{pc}, $c->stash->{latitude}, $c->stash->{longitude} );

    $c->forward('prettify_pc');

    # truncate the lat,lon for nicer urls
    ( $c->stash->{latitude}, $c->stash->{longitude} ) =
      map { Utils::truncate_coordinate($_) }
      ( $c->stash->{latitude}, $c->stash->{longitude} );
    $c->log->debug($_)
      for ( $c->stash->{pc}, $c->stash->{latitude}, $c->stash->{longitude} );

    $c->stash->{council_check_action} = 'alert';
    unless ( $c->forward('/council/load_and_check_councils_and_wards') ) {
        $c->go('index');
    }

    ( $c->stash->{options}, $c->stash->{reported_to_options} ) =
      $c->cobrand->council_rss_alert_options( $c->stash->{all_councils} );

    my $dist =
      mySociety::Gaze::get_radius_containing_population( $c->stash->{latitude},
        $c->stash->{longitude}, 200000 );
    $dist                          = int( $dist * 10 + 0.5 );
    $dist                          = $dist / 10.0;
    $c->stash->{population_radius} = $dist;


    $c->stash->{photos} = $c->cobrand->recent_photos(
        5,
        $c->stash->{latitude},
        $c->stash->{longitude}, $dist
    );

    $c->stash->{cobrand_form_elements} = $c->cobrand->form_elements('alerts');

    $c->stash->{rss_feed_id} =
      sprintf( 'local:%s:%s', $c->stash->{latitude}, $c->stash->{longitude} );

    my $rss_feed;
    if ( $c->stash->{pretty_pc_text} ) {
        $rss_feed =
          $c->cobrand->uri( "/rss/pc/" . $c->stash->{pretty_pc_text},
            $c->fake_q );
    }
    else {
        $rss_feed = $c->cobrand->uri(
            sprintf( "/rss/l/%s,%s",
                $c->stash->{latitude},
                $c->stash->{longitude} ),
            $c->fake_q
        );
    }

    $c->stash->{rss_feed_uri} = $rss_feed;

{'fraction_non_alphanumeric': 0.2215363511659808, 'fraction_numerical': 0.006310013717421125, 'mean_word_length': 2.6509764646970457, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 245, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '966740', 'n_tokens_mistral': 2930, 'n_tokens_neox': 2789, 'n_words': 407}