Gossamer Forum
Quote Reply
Simple Stats Global
Heya all,

I'm looking for a very simple stats global. Assume I have three cateories:

- CatA
- CatB
- CatC

One of the fields in my link is called "Jumper" and can have one of the following 2 values: Good / Bad

All I want (show it to me for one and I should be able to figure out the others Smile) is to show what number and % of links in a specific Cat has the value "Good" or "Bad".

Example output would be something like:

- 6/10 Good Jumpers in Cat1 (60%)
- 4/10 Bad Jumpers in Cat1 (40%)

I'd like to show numbers as actuals and round persentages so there are no decimals. Would also be great if I could do this for top-level categories and include all sub-categories in the calculations.

Safe swoops
Sangiro

Last edited by:

sangiro: Mar 20, 2004, 12:13 PM
Quote Reply
Re: [sangiro] Simple Stats Global In reply to
** Bump **

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Simple Stats Global In reply to
Here's a start (untested):

<%jumperstats($ID)%> where ID is the category id.

sub {
my $id = shift;
my $bad=$DB->table('Links','CatLinks')->count({CategoryID=>$id,Jumper=>'Bad'});
my $good=$DB->table('Links','CatLinks')->countt({CategoryID=>$id,Jumper=>'Good'});
my $total=$bad+$good;
my $goodp = int(($good/$total)*100);
my $badp = int(($bad/$total)*100);
return {GoodP=>$goodp ....}
}

For including subcategories, search the forum for all_ids and you should find some clues.