From: octo Date: Mon, 11 Apr 2005 14:46:23 +0000 (+0000) Subject: Some more work on Userdetails has been done, still not done.. X-Git-Tag: Release-0.8.0~20^2~23 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=de92b3d289c3d0ac159bb339eaad60308a56791a;p=onis.git Some more work on Userdetails has been done, still not done.. --- diff --git a/lib/Onis/Plugins/Bignumbers.pm b/lib/Onis/Plugins/Bignumbers.pm index 3146f5d..2c6c7c1 100644 --- a/lib/Onis/Plugins/Bignumbers.pm +++ b/lib/Onis/Plugins/Bignumbers.pm @@ -3,6 +3,8 @@ package Onis::Plugins::Bignumbers; use strict; use warnings; +use Exporter; + use Onis::Html (qw(get_filehandle)); use Onis::Language (qw(translate)); use Onis::Data::Core (qw(get_main_nick register_plugin)); @@ -10,6 +12,9 @@ use Onis::Data::Persistent (); use Onis::Users (qw(nick_to_name)); use Onis::Plugins::Core (qw(get_core_nick_counters)); +@Onis::Plugins::Bignumbers::EXPORT_OK = (qw(get_bignumbers)); +@Onis::Plugins::Bignumbers::ISA = ('Exporter'); + our $BigNumbers = Onis::Data::Persistent->new ('BigNumbers', 'nick', qw(questions uppercase smiley_happy smiley_sad)); our $CalcData = {}; @@ -391,3 +396,15 @@ sub sort_by_field return (@retval); } + +sub get_bignumbers +{ + my $nick = shift; + + if (!defined ($CalcData->{$nick})) + { + return ({}); + } + + return ($CalcData->{$nick}); +} diff --git a/lib/Onis/Plugins/Userdetails.pm b/lib/Onis/Plugins/Userdetails.pm index 920881f..48723ca 100644 --- a/lib/Onis/Plugins/Userdetails.pm +++ b/lib/Onis/Plugins/Userdetails.pm @@ -11,6 +11,7 @@ use Onis::Users (qw(ident_to_name get_link get_image)); use Onis::Plugin::Core (qw(get_core_nick_counters)); use Onis::Plugin::Conversations (qw(get_conversations)); +use Onis::Plugin::Bignumbers (qw(get_bignumbers)); our $DISPLAY_IMAGES = 0; our $DEFAULT_IMAGE = ''; @@ -153,36 +154,20 @@ sub output $nick_data->{$nick} = get_core_nick_counters ($nick); $nick_data->{$nick}{'conversations'} = get_conversations ($nick); + $nick_data->{$nick}{'bignumbers'} = get_bignumbers ($nick); - if (defined ($DATA->{'byname'}{$name}{'chars_time'})) + for (my $i = 0; $i < 12; $i++) { - for (0..23) - { - next unless (defined ($DATA->{'byname'}{$name}{'chars_time'}{$_})); - if ($DATA->{'byname'}{$name}{'chars_time'}{$_} > $max_time) - { - $max_time = $DATA->{'byname'}{$name}{'chars_time'}{$_}; - } - } + $num = $nick_data->{$nick}{'lines'}[$i] + $nick_data->{$nick}{'lines'}[$i + 1]; + $max_time = $num if ($max_time < $num); } - if (defined ($DATA->{'byname'}{$name}{'conversations'})) - { - my @others = keys (%{$DATA->{'byname'}{$name}{'conversations'}}); - for (@others) - { - my $o = $_; - my $num = 0; - for (0..3) - { - $num += $DATA->{'byname'}{$name}{'conversations'}{$o}[$_]; - } - - if ($num > $max_conv) - { - $max_conv = $num; - } - } + for (keys %{$nick_data->{$nick}{'conversations'}}) + { + my $other = $_; + my $ptr = $nick_data->{$nick}{'conversations'}{'nicks'}{$other}; + $num = $ptr->[0] + $ptr->[1] + $ptr->[2] + $ptr->[3]; + $max_conv = $num if ($max_conv < $num); } } @@ -204,12 +189,15 @@ sub output qq# $trans\n#, qq# \n#; - for (@names) + for (@nicks) { - my $name = $_; + my $nick = $_; + my $name = nick_to_name ($nick); + my $print = $name ? $name : $nick; + my $ptr = $nick_data->{$nick}; print $fh qq# \n#, - qq# $name\n#, + qq# $print\n#, qq# \n#, qq# \n#; @@ -230,7 +218,7 @@ sub output { print $fh qq##; } - print $fh qq#$name#; + print $fh qq#$print#; if ($link) { print $fh ""; @@ -245,31 +233,36 @@ sub output print $fh qq# \n#; - $num = $DATA->{'byname'}{$name}{'lines'}; - $trans = translate ('Has written %u lines'); - printf $fh (" $trans
\n", $num); + { + my $lines; + my $words; + my $chars; - $num = $DATA->{'byname'}{$name}{'words'}; - $trans = translate ('Has written %u words'); - printf $fh (" $trans
\n", $num); + $lines = $ptr->{'lines_total'}; + $trans = translate ('Has written %u lines'); + printf $fh (" $trans
\n", $lines); - $num = $DATA->{'byname'}{$name}{'chars'}; - $trans = translate ('Has written %u chars'); - printf $fh (" $trans
\n", $num); + $words = $ptr->{'words_total'}; + $trans = translate ('Has written %u words'); + printf $fh (" $trans
\n", $words); - if ($DATA->{'byname'}{$name}{'lines'}) - { - $num = $DATA->{'byname'}{$name}{'words'} / $DATA->{'byname'}{$name}{'lines'}; + $chars = $ptr->{'chars_total'}; + $trans = translate ('Has written %u chars'); + printf $fh (" $trans
\n", $chars); + + $num = $words / $lines; $trans = translate ('Has written %.1f words per line'); printf $fh (" $trans
\n", $num); - $num = $DATA->{'byname'}{$name}{'chars'} / $DATA->{'byname'}{$name}{'lines'}; + $num = $chars / $lines; $trans = translate ('Has written %.1f characters per line'); printf $fh (" $trans
\n", $num); } print $fh qq# \n \n#; + # FIXME + if (defined ($DATA->{'byname'}{$name}{'op_given'})) { $num = $DATA->{'byname'}{$name}{'op_given'};