X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=lib%2FOnis%2FPlugins%2FUserdetails.pm;h=1d12dc86fb7bae3f020b1ca822b2e14713841300;hb=7e3c4b5eacb8bcbfff65fdd4d5def64e079991b7;hp=1f846a7ced403ef49ab3755daab8e3d9a49b4ab9;hpb=dbcb0793cb2dd3dc64a445888846d2368b803f5a;p=onis.git diff --git a/lib/Onis/Plugins/Userdetails.pm b/lib/Onis/Plugins/Userdetails.pm index 1f846a7..1d12dc8 100644 --- a/lib/Onis/Plugins/Userdetails.pm +++ b/lib/Onis/Plugins/Userdetails.pm @@ -6,10 +6,12 @@ use warnings; use Onis::Config (qw(get_config)); use Onis::Html (qw(html_escape get_filehandle)); use Onis::Language (qw(translate)); -use Onis::Data::Core (qw(get_main_nick register_plugin nick_to_name)); -use Onis::Users (qw(ident_to_name get_link get_image)); +use Onis::Data::Core (qw(get_main_nick register_plugin nick_to_name get_most_recent_time)); +use Onis::Users (qw(get_link get_image)); use Onis::Plugins::Core (qw(get_core_nick_counters get_sorted_nicklist)); +use Onis::Plugins::Weekdays (qw(get_weekdays)); +use Onis::Plugins::Longterm (qw(get_longterm)); use Onis::Plugins::Conversations (qw(get_conversations)); use Onis::Plugins::Bignumbers (qw(get_bignumbers)); use Onis::Plugins::Interestingnumbers (qw(get_interestingnumbers)); @@ -127,6 +129,14 @@ if (get_config ('bar_width')) $BAR_WIDTH = $tmp if ($tmp >= 10); } +our $LongtermDays = 7; +if (get_config ('userdetails_longterm_days')) +{ + my $tmp = get_config ('userdetails_longterm_days'); + $tmp =~ s/\D//g; + $LongtermDays = $tmp if ($tmp); +} + my $VERSION = '$Id: Userdetails.pm,v 1.5 2005/03/14 18:40:25 octo Exp $'; print STDERR $/, __FILE__, ": $VERSION" if ($::DEBUG); @@ -136,8 +146,6 @@ sub output { my $nicks_ref = get_sorted_nicklist (); - my $max = $PLUGIN_MAX; - my $fh = get_filehandle (); my $trans = translate ('Detailed nick stats'); @@ -145,24 +153,28 @@ sub output my $max_time = 0; my $max_conv = 0; + my $max_weekdays = 0; + my $max_longterm = 0; my @nicks = @$nicks_ref; my $nick_data = {}; - splice (@nicks, $max) if (scalar (@nicks) > $max); + splice (@nicks, $PLUGIN_MAX) if (scalar (@nicks) > $PLUGIN_MAX); for (@nicks) { my $nick = $_; $nick_data->{$nick} = get_core_nick_counters ($nick); + $nick_data->{$nick}{'weekdays'} = get_weekdays ($nick); + $nick_data->{$nick}{'longterm'} = get_longterm ($nick); $nick_data->{$nick}{'conversations'} = get_conversations ($nick); $nick_data->{$nick}{'bignumbers'} = get_bignumbers ($nick); $nick_data->{$nick}{'interestingnumbers'} = get_interestingnumbers ($nick); - for (my $i = 0; $i < 12; $i++) + for (my $i = 0; $i < 24; $i++) { - $num = $nick_data->{$nick}{'chars'}[2 * $i] + $nick_data->{$nick}{'chars'}[(2 * $i) + 1]; + $num = $nick_data->{$nick}{'chars'}[$i]; $max_time = $num if ($max_time < $num); } @@ -173,24 +185,36 @@ sub output $num = $ptr->[0] + $ptr->[1] + $ptr->[2] + $ptr->[3]; $max_conv = $num if ($max_conv < $num); } - } - my $time_factor = 0; - my $conv_factor = 0; + for (keys %{$nick_data->{$nick}{'weekdays'}}) + { + my $ptr = $nick_data->{$nick}{'weekdays'}{$_}; + for (my $i = 0; $i < 4; $i++) + { + $max_weekdays = $ptr->[$i] if ($max_weekdays < $ptr->[$i]); + } + } - if ($max_time) - { - $time_factor = $BAR_HEIGHT / $max_time; - } + if (@{$nick_data->{$nick}{'longterm'}}) + { + my $num = scalar (@{$nick_data->{$nick}{'longterm'}}); + $LongtermDays = $num if ($LongtermDays > $num); - if ($max_conv) - { - $conv_factor = $BAR_WIDTH / $max_conv; + for (my $i = $num - $LongtermDays; $i < $num; $i++) + { + my $ptr = $nick_data->{$nick}{'longterm'}[$i]; + + for (my $j = 0; $j < 4; $j++) + { + $max_longterm = $ptr->[$j] if ($max_longterm < $ptr->[$j]); + } + } + } } - + print $fh qq#\n#, qq# \n#, - qq# \n#, + qq# \n#, qq# \n#; for (@nicks) @@ -201,7 +225,7 @@ sub output my $ptr = $nick_data->{$nick}; print $fh qq# \n#, - qq# \n#, + qq# \n#, qq# \n#, qq# \n#; @@ -304,53 +328,7 @@ sub output printf $fh (" $trans
\n", $num); } - # actions # TODO - # exclamation ratio # TODO - # # of nicks - # - # chats with - # lines per day - - print $fh qq# \n \n \n \n \n
$trans$trans
$print$print
\n#; - - if (defined ($ptr->{'chars'})) - { - print $fh qq# \n \n#; - - for (my $i = 0; $i < 12; $i++) - { - my $hour = 2 * $i; - $num = 0; - - my $img = $V_IMAGES[int ($hour / 6)]; - my $height; - - $num = $ptr->{'chars'}[$hour]; - $num += $ptr->{'chars'}[$hour + 1]; - - $height = int (0.5 + ($time_factor * $num)) || 1; - - print $fh qq# \n#; - } - - print $fh < - - - - - - -
$num chars
0-56-1112-1718-23
-EOF - } - else - { - print ' '; - } - - print $fh qq#
\n#; + print $fh qq# \n#; if (%{$ptr->{'conversations'}}) { @@ -372,7 +350,7 @@ EOF $trans = translate ('Talks to'); print $fh < + @@ -385,13 +363,14 @@ EOF my $total = 0; print $fh " \n", - qq# \n#, - qq# \n#, + qq# \n \n"; @@ -414,6 +393,142 @@ EOF { print $fh ' '; } + print $fh qq# \n \n#, + qq# \n \n \n \n \n#; } print $fh "
$trans:
$other_name#; + qq# $other_name#; for (my $k = 0; $k < 4; $k++) { my $img = $H_IMAGES[$k]; - my $width = int (0.5 + ($conv_factor * $ptr->{'conversations'}{$other}{'nicks'}{$nick}[$k])) || 1; + my $num = $ptr->{'conversations'}{$other}{'nicks'}{$nick}[$k]; + my $width = sprintf ("%.2f", 95 * $num / $max_conv); print $fh qq##; + print $fh qq#style="width: $width\%;" />#; } print $fh "
\n#; + + if (defined ($ptr->{'chars'})) + { + print $fh qq# \n \n#; + + for (my $i = 0; $i < 24; $i++) + { + $num = 0; + + my $img = $V_IMAGES[int ($i / 6)]; + my $height; + + $num = $ptr->{'chars'}[$i]; + + $height = sprintf ("%.2f", 95 * $num / $max_time); + + print $fh qq# \n#; + } + + print $fh < + + + + + + +
$num chars
0-56-1112-1718-23
+EOF + } + else + { + print $fh "  \n"; + } + + print $fh qq#
\n#; + + #weekly + if (%{$nick_data->{$nick}{'weekdays'}}) + { + my $data = $nick_data->{$nick}{'weekdays'}; + my @days = (qw(mon tue wed thu fri sat sun)); + + print $fh qq# \n#, + qq# \n#; + + for (@days) + { + my $day = $_; + for (my $i = 0; $i < 4; $i++) + { + my $num = $nick_data->{$nick}{'weekdays'}{$day}[$i]; + my $height = sprintf ("%.2f", 95 * $num / $max_weekdays); + my $img = $V_IMAGES[$i]; + + print $fh qq# \n#; + } + } + + print $fh qq# \n#, + qq# \n#; + + for (@days) + { + my $day = $_; + my $trans = translate ($day); + + print $fh qq# \n#; + } + + print $fh qq# \n#, + qq#
#, + qq##, + qq#
$trans
\n#; + } + else + { + print $fh "  \n"; + } + + print $fh qq#
\n#; + + #longterm + if (@{$nick_data->{$nick}{'longterm'}}) + { + my $num_fields = scalar (@{$nick_data->{$nick}{'longterm'}}); + my $now_epoch = get_most_recent_time (); + my $now_day = int ($now_epoch / 86400); + my $last_day; + + my @weekdays = (qw(sun mon tue wed thu fri sat)); + + $LongtermDays = $num_fields if ($LongtermDays > $num_fields); + $last_day = 1 + $now_day - $LongtermDays; + + print $fh qq# \n#, + qq# \n#; + + for (my $i = $num_fields - $LongtermDays; $i < $num_fields; $i++) + { + for (my $j = 0; $j < 4; $j++) + { + my $num = $nick_data->{$nick}{'longterm'}[$i][$j]; + my $height = sprintf ("%.2f", 95 * $num / $max_longterm); + my $img = $V_IMAGES[$j]; + + print $fh qq# \n#; + } + } + + print $fh qq# \n#, + qq# \n#; + + for (my $i = 0; $i < $LongtermDays; $i++) + { + my $epoch = ($last_day + $i) * 86400; + my ($day, $wd) = (localtime ($epoch))[3,6]; + $wd = $weekdays[$wd]; + + print $fh qq# \n#; + } + + print $fh qq# \n#, + qq#
#, + qq##, + qq#
$day.
\n#; + } + else + { + print $fh "  \n"; + } + + print $fh qq#
\n\n";