Home : Products : Links 2.0 : Discussions :

Products: Links 2.0: Discussions: Re: [davidarthurs2] latest link entry to top of page: Edit Log

Here is the list of edits for this post
Re: [davidarthurs2] latest link entry to top of page
Same as before... http://www.gossamer-threads.com/...i?post=259393#259393 Is your 'New' page building correctly, listing new links?

The other place to check would be in links.cfg, where you'll see this:

# Build Options
# --------------------------------------------------------
# Setting for popular cutoff, can either be a percent (i.e. top 3%), or
# a fixed value (i.e. top 10). Enter 0.03 or 10 respectively.
$db_popular_cutoff = 0.03; # Top 3%
# Number of days a link is considered New.
$db_new_cutoff = 14; # 14 days old.


Also, in nph-build.cgi is this:

sub build_update_newpop {
# --------------------------------------------------------
# This routines updates the database, and marks new records new,
# old records old, popular records popular, and unpopular records,
# unpopular.

my ($id, %hits, @values, $days, @popular, $cutoff);

# Let's collect how many hits we've gotten.
opendir (HITS, $db_hits_path) or &cgierr ("unable to open hits directory: $db_hits_path. Reason: $!");
while (defined ($id = readdir HITS)) {
next unless ($id =~ /^\d+$/);
open (HIT, "$db_hits_path/$id") or &cgierr ("unable to open hit counter: $db_hits_path/$id. Reason: $!");
$hits{$id} = int <HIT>;
close HIT;
}
closedir HITS;

# Now go through the links database and update new links, and
# add the hits.
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
$values[$db_modified] or print "Warning: No date for line: $_. Skipping..\n" and next LINE;

# Calculate days old and then mark new.
$days = &days_old($values[$db_modified], $date);
($days <= $db_new_cutoff) and ($new_records{$values[$db_key_pos]}++);


# Build an array of popular hits.
exists $hits{$id} ?
push (@popular, $values[$db_hits] + $hits{$id}) :
push (@popular, $values[$db_hits]);
}
close DB;

# Sort the popular list, and set the cutoff mark.
@popular = sort { $b <=> $a } @popular;
($db_popular_cutoff < 1) ?
($cutoff = $popular[int($db_popular_cutoff * $#popular)]) :
($cutoff = $popular[$db_popular_cutoff - 1]);
($cutoff < 2) and ($cutoff = 2);

# Display our cutoffs.
print "\tWhat's New Cutoff: $db_new_cutoff days\n";
print "\tPopular Cutoff: $cutoff hits\n";

# Now update the New and Cool tags on the links.
open (DB, "$db_links_name") or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DBTMP, ">$db_links_name.bak") or &cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
LINE: while (<DB>) {
/^#/ and print OUT and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = split /\Q$db_delim\E/;
$id = $values[0];

# Store the new number of hits.
exists $hits{$id} and ($values[$db_hits] = $values[$db_hits] + $hits{$id});

# Check to see if the record is popular...
if ($values[$db_hits] >= $cutoff) {
print "\tUpdating record: $id, marking as popular ($values[$db_hits]).\n";
$values[$db_ispop] = "Yes";
}
else {
$values[$db_ispop] = "No";
}

# Check to see if the record is new...
if ($new_records{$id}) {
print "\tUpdating record: $id, marking as new.\n";
$values[$db_isnew] = "Yes";
}
else {
$values[$db_isnew] = "No";
}
print DBTMP &join_encode (&array_to_hash(0, @values));
}
close DB;
close DBTMP;

if (-s "$db_links_name.bak" > 0) {
if (! rename ("$db_links_name.bak", $db_links_name)) {
print "\tCouldn't rename! Had to copy. Strange: $!\n";
open (DBTMP, ">$db_links_name") or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DB, "$db_links_name.bak") or &cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
while (<DB>) { print DBTMP; }
close DB;
close DBTMP;
}
}
else {
&cgierr ("Error building! Links database is 0 bytes!");
}

# Finally, clean out the hits directory.
foreach (keys %hits) {
next unless /^\d+$/;
unlink ("$db_hits_path/$_") or &cgierr ("Can't remove hit file: '$db_hits_path/$_'. Reason: $!");
}
}


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Jan 19, 2004, 12:21 PM

Edit Log: