threshold mechanism for checking how much of a post is on the first server

This commit is contained in:
Ward Wouts 2005-11-06 11:50:30 +00:00
parent 68418615fe
commit 20a423aac8
3 changed files with 31 additions and 11 deletions

View file

@ -150,6 +150,8 @@ DELEXT=<pattern> Set extension "mark read" pattern.
OPT_MD=<pattern> Set DELEXT just for multi part messages.
OPT_SD=<pattern> Set DELEXT just for single part messages.
INCLUDEFILE=<file> Include another file, only works in main config.
PRIMARYTHRES=<int> At least this percentage of the post has to be found
on the first server.
Ruby patterns:
--------------

View file

@ -641,6 +641,19 @@ def group_is_complete(subj)
end
end
def group_percentage_primary(subj)
group_subjects unless @grouped
groupsize = @groups[subj]["messageinfo"].length
primarycount = 0
@groups[subj]["messageinfo"].each {|x|
if x[:server] == @serverlist[0]
primarycount += 1
end
}
percentage = ((100.0/groupsize)*primarycount).to_i
return percentage
end
def group_is_singlepart(subj)
@groups[subj]["total"].to_i == 1
end

View file

@ -698,18 +698,23 @@ def main
elsif !(@config[group].has_key?("-X") and i =~ /#{@config[group]["-X"]}/) and
i =~ /#{@config[group]["-I"]}/
print "Match: #{i}\n" if Debuglevel > 0
if @articles.group_is_complete(i) && @articles.group_percentage_primary(i)
begin
if @articles.group_is_singlepart(i)
get_single(i, group)
elsif @articles.group_is_multipart(i)
get_multi(i, group)
if @articles.group_is_complete(i)
if @articles.group_percentage_primary(i) >= ( @config[group].has_key?("PRIMARYTHRES") ?
@config[group]["PRIMARYTHRES"].to_i : 0 )
begin
if @articles.group_is_singlepart(i)
get_single(i, group)
elsif @articles.group_is_multipart(i)
get_multi(i, group)
end
rescue TempError, PermError, YencError
print "#{$!}\n"
print " Skipping article...\n"
#print "Caught #{$!.class}\n"
#print "Error: #{$!}\n"
end
rescue TempError, PermError, YencError
print "#{$!}\n"
print " Skipping article...\n"
#print "Caught #{$!.class}\n"
#print "Error: #{$!}\n"
else
print "Only #{@articles.group_percentage_primary(i)}% of post on primary server, skipping #{i}\n"
end
else
print "Not complete: #{i}\n"