Adding the option to ignore extensions.

This commit is contained in:
Sergiotarxz 2023-05-07 06:12:37 +02:00
parent 81d6a50ce8
commit ae8415758b
2 changed files with 21 additions and 1 deletions

View File

@ -9,7 +9,7 @@ use Data::Dumper;
use BurguillosInfo::Tracking; use BurguillosInfo::Tracking;
use Mojo::Base 'Mojolicious::Controller'; use Mojo::Base 'Mojolicious::Controller', '-signatures';
use DateTime::Format::ISO8601; use DateTime::Format::ISO8601;
use DateTime::Format::Mail; use DateTime::Format::Mail;
@ -37,9 +37,27 @@ sub stats {
} }
my $data = $tracking->get_global_data($self); my $data = $tracking->get_global_data($self);
my $data_per_url = $tracking->get_data_for_urls($self); my $data_per_url = $tracking->get_data_for_urls($self);
$self->_filter_data_per_url($data_per_url);
$self->render(tracking_data => $data, tracking_by_url => $data_per_url); $self->render(tracking_data => $data, tracking_by_url => $data_per_url);
} }
sub _filter_data_per_url($self, $data_per_url) {
my $filter = $self->param('filter');
if (!defined $filter) {
return;
}
my @new_data_per_url;
if ($filter eq 'remove-extensions') {
for my $url (@$data_per_url) {
if ($url->{path} =~ /\.\w+$/) {
next;
}
push @new_data_per_url, $url;
}
}
@$data_per_url = @new_data_per_url;
}
sub submit_login { sub submit_login {
my $self = shift; my $self = shift;
if ($self->valid_login) { if ($self->valid_login) {

View File

@ -6,6 +6,8 @@
<p>Unique visitors last 24 hours <%=$tracking_data->{unique_ips_last_24_hours}%></p> <p>Unique visitors last 24 hours <%=$tracking_data->{unique_ips_last_24_hours}%></p>
<p>Unique visitors last week <%=$tracking_data->{unique_ips_last_week}%></p> <p>Unique visitors last week <%=$tracking_data->{unique_ips_last_week}%></p>
<p>Unique visitors last month <%=$tracking_data->{unique_ips_last_month}%></p> <p>Unique visitors last month <%=$tracking_data->{unique_ips_last_month}%></p>
<p><a href="<%=$base_url.'/stats?filter=remove-extensions'%>">Ver datos sin extensiones.</a></p>
<p><a href="<%=$base_url.'/stats'%>">Ver todo.</a></p>
<table> <table>
<tr> <tr>
<th>Path</th> <th>Path</th>