OK, here is my first attempt. It's a code hack, not a plugin. Please be critical -- I do not claim to be a programmer, so I have no professional feelings that might be injured.
After backing up your database:
Add a new INT column to your Links table named 'OldHits'.
In .../admin/nph-build.cgi, insert the line in red below ...
# -------------------------------------------------------------------
# Determine what we should build.
#
$USE_HTML = defined $ENV{REQUEST_METHOD} ? 1 : 0;
if ($USE_HTML) {
my $do = $IN->param('do') || '';
CASE: {
($do eq 'changed') and build_changed(), last CASE;
($do eq 'staggered') and build_staggered(), last CASE;
($do eq 'repair') and build_repair(), last CASE;
build_all(); # default
}
}
else {
my $arg = $ARGV[0] || '';
CASE: {
($arg eq '--all') and build_all(), last CASE;
($arg eq '--changed') and build_changed(), last CASE;
($arg eq '--repair') and build_repair(), last CASE;
($arg eq '--flags') and build_flags(), last CASE;
($arg eq '--mhits') and build_meaningful_hits(), last CASE;
usage(); # default
}
}
}
In .../admin/nph-build.cgi, add these two functions ...
# ------------------------------------------------------------------
# Reset meaningful hits
#
_header("Resetting meaningful hits.", "Links SQL will now make your Hits meaningful.");
_build_meaningful_hits();
_build_cool_flags();
_footer();
}
sub _build_meaningful_hits {
# ------------------------------------------------------------------
# Resets meaningful hits
#
_time_start();
print "Resetting meaningful hits ... \n";
my $ret = Links::Build::build ('reset_meaningful_hits', shift || {});
print "Done (", _time_display(), " s)\n\n";
return $ret;
}
In .../admin/Links/Build.pm, add these two functions ...
sub build_reset_meaningful_hits {
# ------------------------------------------------------------------
# Reset meaningful hits
#
my ($link_db, $sth, $id, $hits, $oldhits, $diff);
$link_db = $DB->table('Links');
$sth = $link_db->select ( ['ID', 'Hits', 'OldHits'] );
while ( ( $id, $hits, $oldhits) = $sth->fetchrow_array) {
$diff = $hits - $oldhits;
## Play safe ...
if ($diff < 0) {
$diff = 0;
}
$link_db->update (
{OldHits => $diff, Hits => $diff}, {ID => $id}, {GT_SQL_SKIP_CHECK => 1}
);
}
}
END_OF_SUB
Now you can run it as a cron job at intervals which make sense to your project ...
It works for us.
After backing up your database:
Add a new INT column to your Links table named 'OldHits'.
In .../admin/nph-build.cgi, insert the line in red below ...
Code:
sub main { # -------------------------------------------------------------------
# Determine what we should build.
#
$USE_HTML = defined $ENV{REQUEST_METHOD} ? 1 : 0;
if ($USE_HTML) {
my $do = $IN->param('do') || '';
CASE: {
($do eq 'changed') and build_changed(), last CASE;
($do eq 'staggered') and build_staggered(), last CASE;
($do eq 'repair') and build_repair(), last CASE;
build_all(); # default
}
}
else {
my $arg = $ARGV[0] || '';
CASE: {
($arg eq '--all') and build_all(), last CASE;
($arg eq '--changed') and build_changed(), last CASE;
($arg eq '--repair') and build_repair(), last CASE;
($arg eq '--flags') and build_flags(), last CASE;
($arg eq '--mhits') and build_meaningful_hits(), last CASE;
usage(); # default
}
}
}
In .../admin/nph-build.cgi, add these two functions ...
Code:
sub build_meaningful_hits { # ------------------------------------------------------------------
# Reset meaningful hits
#
_header("Resetting meaningful hits.", "Links SQL will now make your Hits meaningful.");
_build_meaningful_hits();
_build_cool_flags();
_footer();
}
sub _build_meaningful_hits {
# ------------------------------------------------------------------
# Resets meaningful hits
#
_time_start();
print "Resetting meaningful hits ... \n";
my $ret = Links::Build::build ('reset_meaningful_hits', shift || {});
print "Done (", _time_display(), " s)\n\n";
return $ret;
}
In .../admin/Links/Build.pm, add these two functions ...
Code:
$SUBS{build_reset_meaningful_hits} = <<'END_OF_SUB'; sub build_reset_meaningful_hits {
# ------------------------------------------------------------------
# Reset meaningful hits
#
my ($link_db, $sth, $id, $hits, $oldhits, $diff);
$link_db = $DB->table('Links');
$sth = $link_db->select ( ['ID', 'Hits', 'OldHits'] );
while ( ( $id, $hits, $oldhits) = $sth->fetchrow_array) {
$diff = $hits - $oldhits;
## Play safe ...
if ($diff < 0) {
$diff = 0;
}
$link_db->update (
{OldHits => $diff, Hits => $diff}, {ID => $id}, {GT_SQL_SKIP_CHECK => 1}
);
}
}
END_OF_SUB
Now you can run it as a cron job at intervals which make sense to your project ...
Code:
.../admin/nph-build.cgi --mhitsIt works for us.