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

Re: [pugdog] Bayesian formula to calculate average ratings

Quote Reply
Re: [pugdog] Bayesian formula to calculate average ratings In reply to
I've just found the post where you discussed this with sangiro and Laura :

http://www.gossamer-threads.com/...i?post=273819#273819

Quote:
Personally I would use
date_get (time, '%ddd% %mmm% %dd% %yyyy%');
but if you want to use date_set_format you really need to set the format back at the end of the sub using
GT::Date::date_set_format($CFG->{'date_db_format'});

setting the date back needs to be done before this :
Quote:
return ($link;

Anyway I'll give it a wirl, but this explains why it isn't in the release version since it can potentially create issues with a mod_perl installation. I have not got mod_perl turned on at the moment but will be aiming to.

Thanks for the help

I'm not that much of a wiz like you with perl but I see that it picks up the IP with $ENV{REMOTE_ADDR} and follow most of it but I can't figure out which field it will be updating as compared to presently where it updates the Detailed_Hits field. Do I need to create a new field for unique hits or does this mod mean that it will now just log unique hits and not all hits ?

This 'should' Blush be the correct version with get_date to avoid the issues discussed by Laura :

Code:
my $ip = $ENV{REMOTE_ADDR} || 'None';
my $click_db = $DB->table ('ClickTrack');
my $DETAILED_CFG = Links::Plugins::get_plugin_user_cfg ('Detailed_Page');
my $column_name = $DETAILED_CFG->{'column_name'};
my $delete_by = $DETAILED_CFG->{'delete_by'};
Links::init_date();
GT::Date::date_get (time, '%ddd% %mmm% %dd% %yyyy%');
$delete_by = GT::Date::date_get ( time() - 18000 ); # 5 HOURS
## do some house keeping on old click-track records.
## these never seem to be deleted.
$click_db->delete(GT::SQL::Condition->new('Created', '<', $delete_by));

my $click_sth = $click_db->select ( { LinkID => $id,
IP => $ip,
ClickType => 'Hits'
} ) or return { error => $GT::SQL::error, LinkID => $id };
if ($click_db->hits) {
my $record = $click_sth->fetchrow_hashref;
my $created = $record->{'Created'};
if ($created < $delete_by) { ## if the record is older than delete_by
$click_db->update (
{ ## refresh the date
Created => \"NOW()"
},
{
LinkID => $id,
IP => $ip,
ClickType => 'Hits'
},
{
GT_SQL_SKIP_INDEX => 1
}
) or return { error => $GT::SQL::error, LinkID => $id };

$LINKDB->update (
{
"$column_name" => \"$column_name + 1"
}, ## set
{
ID => $id ## where
},
{
GT_SQL_SKIP_INDEX => 1 ## cut overhead
}
) or return { error => $GT::SQL::error, LinkID => $id };
}
} else {
## print "No record was found, I'm going to try to update links, and insert click_db<BR>";
$LINKDB->update ( {
"$column_name" => \"$column_name + 1"
},
{
ID => $id
},
{
GT_SQL_SKIP_INDEX => 1
} ) or return { error => $GT::SQL::error, LinkID => $id };
$click_db->insert ( {
LinkID => $id,
IP => $ip,
ClickType => 'Hits',
Created => \"NOW()"
} ) or return { error => $GT::SQL::error, LinkID => $id };
}

I'll try it out with and without mod_perl and let you know how it goes.

John
Significant Media
Subject Author Views Date
Thread Bayesian formula to calculate average ratings sangiro 6349 Oct 7, 2004, 3:17 AM
Post Re: [sangiro] Bayesian formula to calculate average ratings
afinlr 6150 Nov 17, 2004, 11:16 AM
Thread Re: [sangiro] Bayesian formula to calculate average ratings
Jag 6121 Nov 18, 2004, 11:08 AM
Thread Re: [Jag] Bayesian formula to calculate average ratings
pugdog 6088 Dec 29, 2004, 11:37 PM
Thread Re: [pugdog] Bayesian formula to calculate average ratings
pugdog 6069 Dec 29, 2004, 11:45 PM
Thread Re: [pugdog] Bayesian formula to calculate average ratings
Jag 6053 Jan 2, 2005, 2:03 PM
Thread Re: [Jag] Bayesian formula to calculate average ratings
pugdog 6062 Jan 2, 2005, 9:06 PM
Thread Re: [pugdog] Bayesian formula to calculate average ratings
Jag 6081 Jan 3, 2005, 12:23 AM
Thread Re: [Jag] Bayesian formula to calculate average ratings
pugdog 6041 Jan 3, 2005, 6:44 AM
Post Re: [pugdog] Bayesian formula to calculate average ratings
Jag 6044 Jan 3, 2005, 12:00 PM
Post Re: [pugdog] Bayesian formula to calculate average ratings
Jag 6080 Jan 4, 2005, 3:51 PM
Post Re: [sangiro] Bayesian formula to calculate average ratings
lvgltd 6088 Dec 29, 2004, 5:26 PM