Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

rating+votes+reviews score

Quote Reply
rating+votes+reviews score
for example link 1 have

rating 3.32

votes 23

reviews 12

i need to score of it: 3.32+23+12=38,32

Guys, please help with this global.
Quote Reply
Re: [romanslon] rating+votes+reviews score In reply to
sub {
my $id = shift;
my ($votes,$rating)=$DB->table('Links')->select({ID=>$id},['Votes','Rating'])->fetchrow_array;
my $reviews = $DB->table('Reviews')->count({Review_LinkID=>$id});
my $total = $votes+$rating+$reviews;
return "Votes: $votes, Rating: $rating, Reviews: $reviews, Total: $total";
}

Call it with <%name_of_global($ID)%>
Quote Reply
Re: [afinlr] rating+votes+reviews score In reply to
works fine.

thanks!
Quote Reply
Re: [afinlr] rating+votes+reviews score In reply to
Laura,

I'd like to change this score formula to use: Average Review Rating * Number of Reviews

...and then print the Top 10 links with the highest "score"? Smile

Safe swoops
Sangiro

Last edited by:

sangiro: Sep 30, 2004, 3:24 AM
Quote Reply
Re: [sangiro] rating+votes+reviews score In reply to
I am not a pro.. but I think playing with
Quote:
my $total = $votes+$rating+$reviews;
should do the trick.

P.S.. wow.. Laura, I have been looking for something like this for months and you solved the problem in a second... you are wonderful.. Thank you again.

Vishal

Vishal
-------------------------------------------------------
Quote Reply
Re: [sangiro] rating+votes+reviews score In reply to
Don't ask for much do you Wink.

Try this (note that you'll need to change the red prefix for your setup):

sub {
my $table = $DB->table('Reviews','Links');
$table->select_options ("GROUP BY Review_LinkID", "ORDER BY total DESC", "LIMIT 10");
my $sth = $table->select(['SUM(Review_Rating) AS total','lsql_Links.*']);
my $output;
while (my $rec=$sth->fetchrow_hashref){
$output .= "<li>$rec->{'Title'} ($rec->{'total'})";
}
return $output;
}
Quote Reply
Re: [NeedScripts.Com] rating+votes+reviews score In reply to
Blush
Quote Reply
Re: [afinlr] rating+votes+reviews score In reply to
Quote:
Don't ask for much do you.

If it's worth doing then it's worth doing well! Wink

I tried this. Changed the prefix to that of the db tables I want it to look at and it returns nothing. No error, but no result either.

rank_total
Quote:
sub {
my $table = $DB->table('Reviews','Links');
$table->select_options ("GROUP BY Review_LinkID", "ORDER BY total DESC", "LIMIT 10");
my $sth = $table->select(['SUM(Review_Rating) AS total','kb_Links.*']);
my $output;
while (my $rec=$sth->fetchrow_hashref){
$output .= "<li>$rec->{'Title'} ($rec->{'total'})";
}
return $output;
}
I just called it with a tag of the global name.... <%rank_total%>

Thanks!

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] rating+votes+reviews score In reply to
Hmm - think I tested this on my site when I wrote it. I assume you're using mysql - what version is it?
Quote Reply
Re: [afinlr] rating+votes+reviews score In reply to
Blech... you don't ask for much do you! Sly

I have no idea what the exact version is, but yes it is mySQL. I'll ping Alex for that one. Smile

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] rating+votes+reviews score In reply to
Sorry - I've just looked at this again and you don't need the prefix on the table in the select statement (I've had so many problems with table prefixes in my stats plugins that I saw a table name and thought 'prefix') and this may solve the problem.
Quote Reply
Re: [afinlr] rating+votes+reviews score In reply to
Nope - no joy. That didn't do it. Still no output at all.

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] rating+votes+reviews score In reply to
Can you try this in mysql monitor:

SELECT SUM(Review_Rating) AS total, kb_Links.* FROM kb_Links,kb_Reviews WHERE kb_Reviews.Review_LinkID = kb_Links.ID GROUP BY Review_LinkID ORDER BY total DESC LIMIT 10

Last edited by:

afinlr: Oct 6, 2004, 2:17 PM
Quote Reply
Re: [afinlr] rating+votes+reviews score In reply to
I get:

Quote:
A fatal error has occured:

GT::SQL::Table (25348): Unknown method 'row_names' called at /path/to/cgi-bin/gear/admin/Links/Tools.pm line 1299.

Please enable debugging in setup for more details.

Just so you know... this was actually executed in:

/path/to/cgi-bin/safety/admin/Links/ (not "gear")

mod_perl preloads the gear module and shares it.

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] rating+votes+reviews score In reply to
Not really sure what to suggest as I don't have 'row_names' in my Tools.pm file. Maybe you could try turning on debugging as it suggests and see whether there is any more information?
Quote Reply
Re: [afinlr] rating+votes+reviews score In reply to
Done this and get a stack trace and the typical stuff. I sent it to you via PM so you can take a look if you thin it'll help. I quite frankly don't have "row_names" in Tools.pm either. I'm wondering if this is from a plugin... Crazy

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] rating+votes+reviews score In reply to
Ok - just as an FYI for others finding this thread. Laura's global (without the kb_) works. I was being daft. Blush

Safe swoops
Sangiro
Quote Reply
Re: [afinlr] rating+votes+reviews score In reply to
Is there someone who played a litte bit more with this global.
I think just adding rating+number of votes + reviews score gives not really a fair result.

I'm not good in mathematics but perhaps there is a better formula ?!?

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] rating+votes+reviews score In reply to
If someone comes up with the math to get a good result, I should be able to write a global for it =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] rating+votes+reviews score In reply to
Hi Andy,
I found one in the forum
http://www.gossamer-threads.com/...ngs_P273406/#p273406 (great shortcut w00t )

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] rating+votes+reviews score In reply to
Did it work? :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] rating+votes+reviews score In reply to
I don't know! I just searched for a formula, that makes more sense, but the code in this thread is for an older links version and I don't want to change the code, looking just for a global...

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] rating+votes+reviews score In reply to
Ah ok - I thought you had tried it :P

I'll have a look at it later (time permitting) ... and see if I can come up with something :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] rating+votes+reviews score In reply to
Hi Andy,
any news for this global ;-)

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] rating+votes+reviews score In reply to
Sorry not had a chance, been really busy (not a bad thing mind Wink)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Matthias70] rating+votes+reviews score In reply to
Ok, well not sure its as simple as just having a global to do this (would be too heavy on the server = ))

I'd suggest maybe a new field, and then a script that will do the math, and update the field (so you can set the script to run maybe once a day , or whatever)

If I get some time today, I'll see if I can come up with something. No promises though Wink

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!