Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

The following simplistic patch adds reports that differentiate between Re: nodes reputation and top-level articles reputation, based on the idea that those two categories are often voted on differently.

--- statswhore_old.pl Wed Mar 28 15:27:03 2001 +++ statswhore.pl Wed Mar 28 15:24:24 2001 @@ -59,13 +59,44 @@ $total += @$_[1] for (@$rarticles); @$rarticles = sort {@$a[1] <=> @$b[1]} @$rarticles; + # added by darobin + my (@top_articles,@re_articles); + my $top_total = 0; + my $re_total = 0; + for my $art (@$rarticles) { + $art->[0] =~ s/^node_id=\d+://i; + if ($art->[0] =~ /^\s*Re:/i) { + push @re_articles, $art; + $re_total += $art->[1]; + } + else { + push @top_articles, $art; + $top_total += $art->[1]; + } + } + @top_articles = sort { $a->[1] <=> $b->[1] } @top_articles; + @re_articles = sort { $a->[1] <=> $b->[1] } @re_articles; + print "\n"; - print sprintf (" User: %s\n", $username); - print sprintf (" Total articles: %d\n", $#$rarticles + 1); - print sprintf (" Total reputation: %d\n", $total); - print sprintf (" Min reputation: %d\n", @$rarticles [0]->[1] +); - print sprintf (" Max reputation: %d\n", @$rarticles [-1]->[1 +]); - print sprintf ("Average reputation: %3.2f\n", $total / ($#$rarticl +es + 1)); + print sprintf (" User: %s\n", $userna +me); + print sprintf (" Total articles: %d\n", $#$rart +icles + 1); + print sprintf (" Total reputation: %d\n", $total) +; + print sprintf (" Min reputation: %d\n", @$rarti +cles [0]->[1]); + print sprintf (" Max reputation: %d\n", @$rarti +cles [-1]->[1]); + print sprintf (" Avg reputation: %3.2f\n\n", $tota +l / ($#$rarticles + 1)); + + print sprintf (" Total top-level posts: %d\n", scalar @to +p_articles); + print sprintf ("Total top-level post reputation: %d\n", $top_total +); + print sprintf (" Max top-level post reputation: %d\n", $top_artic +les[-1]->[1]); + print sprintf (" Min top-level post reputation: %d\n", $top_artic +les[0]->[1]); + print sprintf (" Avg top-level post reputation: %3.2f\n\n", (@top +_articles)?($top_total / scalar @top_articles):0); + + print sprintf (" Total reply posts: %d\n", scalar @re +_articles); + print sprintf (" Total reply post reputation: %d\n", $re_total) +; + print sprintf (" Max reply post reputation: %d\n", $re_articl +es[-1]->[1]); + print sprintf (" Min reply post reputation: %d\n", $re_articl +es[0]->[1]); + print sprintf (" Avg reply post reputation: %3.2f\n", (@re_ar +ticles)?($re_total / scalar @re_articles):0); + print "\n"; }

-- darobin


In reply to Re: statswhore.pl by darobin
in thread statswhore.pl by jcwren

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (4)
    As of 2015-07-04 02:46 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (57 votes), past polls