diff --git a/mdl/m_quicksort.pas b/mdl/m_quicksort.pas index f280fa5..b5235a3 100644 --- a/mdl/m_quicksort.pas +++ b/mdl/m_quicksort.pas @@ -24,7 +24,7 @@ Type Destructor Destroy; Override; 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 Clear; End; @@ -73,20 +73,27 @@ Begin Result := True; End; -Procedure TQuickSort.Conditional (Name: String; Ptr: Cardinal; ListMin: Word); +Procedure TQuickSort.Conditional (Name: String; Ptr: Cardinal; ListMin: Word; Mode: TSortMethod); Var Count : Word; + Ok : Boolean; Begin If Total < ListMin Then Self.Add(Name, Ptr) Else - For Count := Total DownTo 1 Do - If Data[Count]^.Name < Name Then Begin + For Count := Total DownTo 1 Do 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]^.Ptr := Ptr; Break; End; + End; End; Procedure TQuickSort.Sort (Left, Right: Word; Mode: TSortMethod); diff --git a/mystic/mutil.cfg b/mystic/mutil.cfg index df61b38..51cf0d2 100644 --- a/mystic/mutil.cfg +++ b/mystic/mutil.cfg @@ -20,7 +20,7 @@ ; - Import FIDONET.NA into Message bases ; - Import FILEBONE.NA into File bases ; - 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 + ; 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 ; @NA=name @DA=calls @@ -207,3 +216,10 @@ top_post_desc = Posters top_post_namelen = 30 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 diff --git a/mystic/mutil_toplists.pas b/mystic/mutil_toplists.pas index 0a8bd50..00e166c 100644 --- a/mystic/mutil_toplists.pas +++ b/mystic/mutil_toplists.pas @@ -16,7 +16,7 @@ Uses mutil_Status; Type - TopListType = (TopCall, TopPost, TopDL, TopUL); + TopListType = (TopCall, TopPost, TopDL, TopUL, TopPCR); Var CreatedLists : LongInt = 0; @@ -29,11 +29,14 @@ Var Function GetValue : Cardinal; Begin + Result := 0; + Case ListType of TopCall : Result := User.Calls; TopPost : Result := User.Posts; TopDL : Result := User.DLs; TopUL : Result := User.ULs; + TopPCR : If User.Calls > 0 Then Result := Round(User.Posts / User.Calls * 100); End; End; @@ -80,6 +83,7 @@ Var TopPost : CfgName := '_post_'; TopDL : CfgName := '_dl_'; TopUL : CfgName := '_ul_'; + TopPCR : CfgName := '_pcr_'; End; Template := INI.ReadString (Header_TopLists, 'top' + CfgName + 'template', 'template.txt'); @@ -118,8 +122,14 @@ Var CodeVal := CodeVal + GetChar; If (CodeVal[1] in ['0'..'9']) And (CodeVal[2] in ['0'..'9']) Then Begin - UserFile.Seek (Pred(Sort.Data[strS2I(CodeVal)]^.Ptr)); - UserFile.Read (User); + If Sort.Data[strS2I(CodeVal)] <> NIL Then Begin + 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 Write (OutFile, strPadR(User.Handle, NameLen, ' ')) @@ -146,6 +156,7 @@ Var ExclName : String; Str : String; Excluded : Boolean; + SortMode : TSortMethod; Begin Result := True; @@ -154,10 +165,16 @@ Begin TopPost : ProcessStatus('Top Posts'); TopDL : ProcessStatus('Top Downloaders'); TopUL : ProcessStatus('Top Uploaders'); + TopPCR : ProcessStatus('Top Post/Call Ratio'); End; 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; UserFile := TBufFile.Create(8192); @@ -195,10 +212,10 @@ Begin End; 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; - Sort.Sort (1, Sort.Total, qDescending); + Sort.Sort (1, Sort.Total, SortMode); GenerateOutput; @@ -220,9 +237,10 @@ Begin 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_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)'); ProcessResult (rDONE, True); End; -End. \ No newline at end of file +End.