Bug fix and new stuff

This commit is contained in:
mysticbbs 2012-03-10 18:07:47 -05:00
parent 55eb65c029
commit 8c65344dd6
3 changed files with 52 additions and 11 deletions

View File

@ -24,7 +24,7 @@ Type
Destructor Destroy; Override; Destructor Destroy; Override;
Function Add (Name: String; Ptr: Cardinal) : Boolean; Function Add (Name: String; Ptr: Cardinal) : Boolean;
Procedure Conditional (Name: String; Ptr: Cardinal; ListMin: Word); Procedure Conditional (Name: String; Ptr: Cardinal; ListMin: Word; Mode: TSortMethod);
Procedure Sort (Left, Right: Word; Mode: TSortMethod); Procedure Sort (Left, Right: Word; Mode: TSortMethod);
Procedure Clear; Procedure Clear;
End; End;
@ -73,20 +73,27 @@ Begin
Result := True; Result := True;
End; End;
Procedure TQuickSort.Conditional (Name: String; Ptr: Cardinal; ListMin: Word); Procedure TQuickSort.Conditional (Name: String; Ptr: Cardinal; ListMin: Word; Mode: TSortMethod);
Var Var
Count : Word; Count : Word;
Ok : Boolean;
Begin Begin
If Total < ListMin Then If Total < ListMin Then
Self.Add(Name, Ptr) Self.Add(Name, Ptr)
Else Else
For Count := Total DownTo 1 Do For Count := Total DownTo 1 Do Begin
If Data[Count]^.Name < Name Then Begin Case Mode of
qDescending : Ok := Data[Count]^.Name < Name;
qAscending : Ok := Data[Count]^.Name > Name;
End;
If Ok Then Begin
Data[Count]^.Name := Name; Data[Count]^.Name := Name;
Data[Count]^.Ptr := Ptr; Data[Count]^.Ptr := Ptr;
Break; Break;
End; End;
End;
End; End;
Procedure TQuickSort.Sort (Left, Right: Word; Mode: TSortMethod); Procedure TQuickSort.Sort (Left, Right: Word; Mode: TSortMethod);

View File

@ -20,7 +20,7 @@
; - Import FIDONET.NA into Message bases ; - Import FIDONET.NA into Message bases
; - Import FILEBONE.NA into File bases ; - Import FILEBONE.NA into File bases
; - Mass upload files to all file bases (with FILE_ID.DIZ import) ; - Mass upload files to all file bases (with FILE_ID.DIZ import)
; - Generate Top 1 up to 99 Callers, Posters, Downloaders, and Uploaders ; - Generate Top 1 up to 99 Callers, Posters, Downloaders, Uploaders, PCR
; ;
; ========================================================================== ; ==========================================================================
; ========================================================================== ; ==========================================================================
@ -174,6 +174,15 @@
exclude_list = mutil.toplist.exclude.txt exclude_list = mutil.toplist.exclude.txt
; User name for "no one" when for example you have 3 users and make a
; top 10 list
no_user = No one
; Sort order. You can use this to calculate top or bottom 99. 1=top
sort_top=1
; configuration for top callers generator ; configuration for top callers generator
; @NA=name @DA=calls ; @NA=name @DA=calls
@ -207,3 +216,10 @@
top_post_desc = Posters top_post_desc = Posters
top_post_namelen = 30 top_post_namelen = 30
top_post_datalen = 10 top_post_datalen = 10
top_pcr = 1
top_pcr_template = mutil.toplist.template.txt
top_pcr_output = toppcr.asc
top_pcr_desc = Posts Per Call
top_pcr_namelen = 30
top_pcr_datalen = 10

View File

@ -16,7 +16,7 @@ Uses
mutil_Status; mutil_Status;
Type Type
TopListType = (TopCall, TopPost, TopDL, TopUL); TopListType = (TopCall, TopPost, TopDL, TopUL, TopPCR);
Var Var
CreatedLists : LongInt = 0; CreatedLists : LongInt = 0;
@ -29,11 +29,14 @@ Var
Function GetValue : Cardinal; Function GetValue : Cardinal;
Begin Begin
Result := 0;
Case ListType of Case ListType of
TopCall : Result := User.Calls; TopCall : Result := User.Calls;
TopPost : Result := User.Posts; TopPost : Result := User.Posts;
TopDL : Result := User.DLs; TopDL : Result := User.DLs;
TopUL : Result := User.ULs; TopUL : Result := User.ULs;
TopPCR : If User.Calls > 0 Then Result := Round(User.Posts / User.Calls * 100);
End; End;
End; End;
@ -80,6 +83,7 @@ Var
TopPost : CfgName := '_post_'; TopPost : CfgName := '_post_';
TopDL : CfgName := '_dl_'; TopDL : CfgName := '_dl_';
TopUL : CfgName := '_ul_'; TopUL : CfgName := '_ul_';
TopPCR : CfgName := '_pcr_';
End; End;
Template := INI.ReadString (Header_TopLists, 'top' + CfgName + 'template', 'template.txt'); Template := INI.ReadString (Header_TopLists, 'top' + CfgName + 'template', 'template.txt');
@ -118,8 +122,14 @@ Var
CodeVal := CodeVal + GetChar; CodeVal := CodeVal + GetChar;
If (CodeVal[1] in ['0'..'9']) And (CodeVal[2] in ['0'..'9']) Then Begin If (CodeVal[1] in ['0'..'9']) And (CodeVal[2] in ['0'..'9']) Then Begin
UserFile.Seek (Pred(Sort.Data[strS2I(CodeVal)]^.Ptr)); If Sort.Data[strS2I(CodeVal)] <> NIL Then Begin
UserFile.Read (User); UserFile.Seek (Pred(Sort.Data[strS2I(CodeVal)]^.Ptr));
UserFile.Read (User);
End Else Begin
FillChar (User, SizeOf(User), 0);
User.Handle := INI.ReadString(Header_TopLists, 'no_user', 'No one');
End;
If Code = 'NA' Then If Code = 'NA' Then
Write (OutFile, strPadR(User.Handle, NameLen, ' ')) Write (OutFile, strPadR(User.Handle, NameLen, ' '))
@ -146,6 +156,7 @@ Var
ExclName : String; ExclName : String;
Str : String; Str : String;
Excluded : Boolean; Excluded : Boolean;
SortMode : TSortMethod;
Begin Begin
Result := True; Result := True;
@ -154,10 +165,16 @@ Begin
TopPost : ProcessStatus('Top Posts'); TopPost : ProcessStatus('Top Posts');
TopDL : ProcessStatus('Top Downloaders'); TopDL : ProcessStatus('Top Downloaders');
TopUL : ProcessStatus('Top Uploaders'); TopUL : ProcessStatus('Top Uploaders');
TopPCR : ProcessStatus('Top Post/Call Ratio');
End; End;
ExclName := INI.ReadString(Header_TopLists, 'exclude_list', 'exclude.txt'); ExclName := INI.ReadString(Header_TopLists, 'exclude_list', 'exclude.txt');
If INI.ReadInteger(Header_TopLists, 'sort_top', 1) = 1 Then
SortMode := qDescending
Else
SortMode := qAscending;
BarOne.Reset; BarOne.Reset;
UserFile := TBufFile.Create(8192); UserFile := TBufFile.Create(8192);
@ -195,10 +212,10 @@ Begin
End; End;
If Not Excluded Then If Not Excluded Then
Sort.Conditional(strPadL(strI2S(GetValue), 10, '0'), UserFile.FilePos, 99); Sort.Conditional(strPadL(strI2S(GetValue), 10, '0'), UserFile.FilePos, 99, SortMode);
End; End;
Sort.Sort (1, Sort.Total, qDescending); Sort.Sort (1, Sort.Total, SortMode);
GenerateOutput; GenerateOutput;
@ -220,6 +237,7 @@ Begin
If INI.ReadString(Header_TopLists, 'top_post', '0') = '1' Then GenerateList(TopPost); If INI.ReadString(Header_TopLists, 'top_post', '0') = '1' Then GenerateList(TopPost);
If INI.ReadString(Header_TopLists, 'top_dl', '0') = '1' Then GenerateList(TopDL); If INI.ReadString(Header_TopLists, 'top_dl', '0') = '1' Then GenerateList(TopDL);
If INI.ReadString(Header_TopLists, 'top_ul', '0') = '1' Then GenerateList(TopUL); If INI.ReadString(Header_TopLists, 'top_ul', '0') = '1' Then GenerateList(TopUL);
If INI.ReadString(Header_TopLists, 'top_pcr', '0') = '1' Then GenerateList(TopPCR);
ProcessStatus ('Created |15' + strI2S(CreatedLists) + ' |07list(s)'); ProcessStatus ('Created |15' + strI2S(CreatedLists) + ' |07list(s)');
ProcessResult (rDONE, True); ProcessResult (rDONE, True);