<commit_before>
package VNDB::Handler::Users;

use strict;
use warnings;
use YAWF ':html', 'xml_escape';
use VNDB::Func;
use POSIX 'floor';


YAWF::register(
  qr{u([1-9]\d*)}             => \&userpage,
  qr{u/login}                 => \&login,
  qr{u([1-9]\d*)/logout}      => \&logout,
  qr{u/newpass}               => \&newpass,
  qr{u/newpass/sent}          => \&newpass_sent,
  qr{u/register}              => \&register,
  qr{u([1-9]\d*)/edit}        => \&edit,
  qr{u([1-9]\d*)/posts}       => \&posts,
  qr{u([1-9]\d*)/del(/[od])?} => \&delete,
  qr{u/(all|[0a-z])}          => \&list,
  qr{u([1-9]\d*)/notifies}    => \&notifies,
  qr{u([1-9]\d*)/notify/([1-9]\d*)} => \&readnotify,
);


sub userpage {
  my($self, $uid) = @_;

  my $u = $self->dbUserGet(uid => $uid, what => 'stats')->[0];
  return 404 if !$u->{id};

  my $votes = $u->{c_votes} && $self->dbVoteStats(uid => $uid);

  my $title = mt '_userpage_title', $u->{username};
  $self->htmlHeader(title => $title, noindex => 1);
  $self->htmlMainTabs('u', $u);
  div class => 'mainbox userpage';
   h1 $title;

   table;
    my $i = 0;

    Tr ++$i % 2 ? (class => 'odd') : ();
     td class => 'key', mt '_userpage_username';
     td;
      txt ucfirst($u->{username}).' (';
      a href => "/u$uid", "u$uid";
      txt ')';
     end;
    end;

    Tr ++$i % 2 ? (class => 'odd') : ();
     td mt '_userpage_registered';
     td $self->{l10n}->date($u->{registered});
    end;

    Tr ++$i % 2 ? (class => 'odd') : ();
     td mt '_userpage_edits';
     td;
      if($u->{c_changes}) {
        a href => "/u$uid/hist", $u->{c_changes};
      } else {
        txt '-';
      }
     end;
    end;

    Tr ++$i % 2 ? (class => 'odd') : ();
     td mt '_userpage_votes';
     td;
      if(!$u->{show_list}) {
        txt mt '_userpage_hidden';
      } elsif($votes) {
        my($total, $count) = (0, 0);
        for (1..@$votes) {
          $total += $_*$votes->[$_-1];
          $count += $votes->[$_-1];
        }
        lit mt '_userpage_votes_item', "/u$uid/list?v=1", $count, sprintf '%.2f', $total/$count;
      } else {
        txt '-';
      }
     end;
    end;

    Tr ++$i % 2 ? (class => 'odd') : ();
     td mt '_userpage_tags';
     td;
      if(!$u->{c_tags}) {
        txt '-';
      } else {
        txt mt '_userpage_tags_item', $u->{c_tags}, $u->{tagcount}, $u->{tagvncount};
        txt ' ';
        a href => "/g/links?u=$uid"; lit mt('_userpage_tags_browse').' &raquo;'; end;
      }
     end;
    end;

    Tr ++$i % 2 ? (class => 'odd') : ();
     td mt '_userpage_list';
     td !$u->{show_list} ? mt('_userpage_hidden') :
       mt('_userpage_list_item', $u->{releasecount}, $u->{vncount});
    end;

    Tr ++$i % 2 ? (class => 'odd') : ();<commit_msg>Handler::Users: Link the vote count on /u+ to /u+/votes instead of /u+/list<commit_after>
package VNDB::Handler::Users;

use strict;
use warnings;
use YAWF ':html', 'xml_escape';
use VNDB::Func;
use POSIX 'floor';


YAWF::register(
  qr{u([1-9]\d*)}             => \&userpage,
  qr{u/login}                 => \&login,
  qr{u([1-9]\d*)/logout}      => \&logout,
  qr{u/newpass}               => \&newpass,
  qr{u/newpass/sent}          => \&newpass_sent,
  qr{u/register}              => \&register,
  qr{u([1-9]\d*)/edit}        => \&edit,
  qr{u([1-9]\d*)/posts}       => \&posts,
  qr{u([1-9]\d*)/del(/[od])?} => \&delete,
  qr{u/(all|[0a-z])}          => \&list,
  qr{u([1-9]\d*)/notifies}    => \&notifies,
  qr{u([1-9]\d*)/notify/([1-9]\d*)} => \&readnotify,
);


sub userpage {
  my($self, $uid) = @_;

  my $u = $self->dbUserGet(uid => $uid, what => 'stats')->[0];
  return 404 if !$u->{id};

  my $votes = $u->{c_votes} && $self->dbVoteStats(uid => $uid);

  my $title = mt '_userpage_title', $u->{username};
  $self->htmlHeader(title => $title, noindex => 1);
  $self->htmlMainTabs('u', $u);
  div class => 'mainbox userpage';
   h1 $title;

   table;
    my $i = 0;

    Tr ++$i % 2 ? (class => 'odd') : ();
     td class => 'key', mt '_userpage_username';
     td;
      txt ucfirst($u->{username}).' (';
      a href => "/u$uid", "u$uid";
      txt ')';
     end;
    end;

    Tr ++$i % 2 ? (class => 'odd') : ();
     td mt '_userpage_registered';
     td $self->{l10n}->date($u->{registered});
    end;

    Tr ++$i % 2 ? (class => 'odd') : ();
     td mt '_userpage_edits';
     td;
      if($u->{c_changes}) {
        a href => "/u$uid/hist", $u->{c_changes};
      } else {
        txt '-';
      }
     end;
    end;

    Tr ++$i % 2 ? (class => 'odd') : ();
     td mt '_userpage_votes';
     td;
      if(!$u->{show_list}) {
        txt mt '_userpage_hidden';
      } elsif($votes) {
        my($total, $count) = (0, 0);
        for (1..@$votes) {
          $total += $_*$votes->[$_-1];
          $count += $votes->[$_-1];
        }
        lit mt '_userpage_votes_item', "/u$uid/votes", $count, sprintf '%.2f', $total/$count;
      } else {
        txt '-';
      }
     end;
    end;

    Tr ++$i % 2 ? (class => 'odd') : ();
     td mt '_userpage_tags';
     td;
      if(!$u->{c_tags}) {
        txt '-';
      } else {
        txt mt '_userpage_tags_item', $u->{c_tags}, $u->{tagcount}, $u->{tagvncount};
        txt ' ';
        a href => "/g/links?u=$uid"; lit mt('_userpage_tags_browse').' &raquo;'; end;
      }
     end;
    end;

    Tr ++$i % 2 ? (class => 'odd') : ();
     td mt '_userpage_list';
     td !$u->{show_list} ? mt('_userpage_hidden') :
       mt('_userpage_list_item', $u->{releasecount}, $u->{vncount});
    end;

    Tr ++$i % 2 ? (class => 'odd') : ();
{'fraction_non_alphanumeric': 0.24743196972427464, 'fraction_numerical': 0.014236799423319516, 'mean_word_length': 2.10576385002798, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 109, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1173967', 'n_tokens_mistral': 2341, 'n_tokens_neox': 2250, 'n_words': 439}