Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Top Poster Idea stolen from ASP.NET Forums
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

dayve
Forum Moderator

USA
5820 Posts

Posted - 09 March 2003 :  14:20:58  Show Profile  Visit dayve's Homepage
I was browsing through the ASP.NET forums and saw a Top Poster feature (see: http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=115769 ) that I thought would be cool to make a mod out of. I have successfully incorporated the mod, but before I package it up I would like some ideas on how to make this streamlined and more efficient. Here is a screenshot first:



currently the sql statement and code I used is:

strSql = "SELECT TOP 25 M.MEMBER_ID "
strSql = strSql & "FROM FORUM_MEMBERS M "
strSql = strSql & "WHERE M.M_NAME <> 'n/a' "
strSql = strSql & "ORDER BY M.M_POSTS DESC"
tPosition = ""
tCount = 1
set rsPost = my_Conn.Execute(strSql)
do while not (rsPost.EOF or rsPost.BOF)

if rsPost("MEMBER_ID") = Reply_MemberID and tCount <=5 then tPosition = "Top 5 Poster ("&tCount&")"
if rsPost("MEMBER_ID") = Reply_MemberID and tCount >5 and tCount <=10 then tPosition = "Top 10 Poster ("&tCount&")"
if rsPost("MEMBER_ID") = Reply_MemberID and tCount >10 and tCount <=25 then tPosition = "Top 25 Poster ("&tCount&")"

tCount = tCount + 1
rsPost.MoveNext
loop

rsPost.close
set rsPost = nothing


and then I place the variable tPosition wherever I want the results to show which I have under the members post count. the number in parenthesis signifies their position in the top 25. I know I could make this more dynamic with an administrative control panel which I am currently working on, but for effeciency on database hits, what can I do to improve it? I have not noticed any major performace degradations right now but I'd gladly accept some input on this.

thanks in advance.


dayve
Forum Moderator

USA
5820 Posts

Posted - 09 March 2003 :  14:23:56  Show Profile  Visit dayve's Homepage
well, one thing I just realized was I should probably edit the conditional statement to this:

if rsPost("MEMBER_ID") = Reply_MemberID then
 if tCount <=5 then tPosition = "Top 5 Poster ("&tCount&")"
 if tCount >5 and tCount <=10 then tPosition = "Top 10 Poster ("&tCount&")"
 if tCount >10 and tCount <=25 then tPosition = "Top 25 Poster ("&tCount&")"
end if

Go to Top of Page

pweighill
Junior Member

United Kingdom
453 Posts

Posted - 09 March 2003 :  15:32:43  Show Profile
How often do you call this query per page?

You could use the GetRows function to store the data in an array and then just use that in the rest of the page.

set rsPost = my_Conn.Execute(strSql)
arrTopPosters = rsPost.GetRows(25)
rsPost.close
set rsPost = nothing

tPosition = ""
for i= 1 to 25
 if arrTopPosters(0,i-1)  = Reply_MemberID then
  if i <=5 then
   tPosition = "Top 5 Poster ("&tCount&")"
  elseif i <=10 then
   tPosition = "Top 10 Poster ("&tCount&")"
  else
   tPosition = "Top 25 Poster ("&tCount&")"
  end if
 end if
next
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 09 March 2003 :  15:59:20  Show Profile
pweighill's suggestion will be a better approach, just need little correction, highlighted in red

set rsPost = my_Conn.Execute(strSql)
arrTopPosters = rsPost.GetRows(25)
rsPost.close
set rsPost = nothing

tPosition = ""
for i= 1 to 25
 if arrTopPosters(0,i-1)  = Reply_MemberID then
  if i <=5 then
   tPosition = "Top 5 Poster ("& i &")"
  elseif i <=10 then
   tPosition = "Top 10 Poster ("& i &")"
  else
   tPosition = "Top 25 Poster ("& i &")"
  end if
 end if
next
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 09 March 2003 :  15:59:51  Show Profile  Visit dayve's Homepage
how would I get the individual member id's without nesting this routine in an existing loop? I understand the logic, but not sure how it could be done in topic.asp in order to hit the db once.

Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 09 March 2003 :  16:02:26  Show Profile
You need to get the top poster ID's and store them in an array and then compare the individual Member ID (Topic Author or Reply Poster) with the Id's in array.
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 09 March 2003 :  16:03:32  Show Profile  Visit dayve's Homepage
yeah, I just saw how that was done in topic.asp for the replies... I think I understand what I need to do now. thanks.

Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 09 March 2003 :  16:21:17  Show Profile  Visit dayve's Homepage
Got it working... thanks guys.

Go to Top of Page

PeeWee.Inc
Senior Member

United Kingdom
1893 Posts

Posted - 09 March 2003 :  16:30:58  Show Profile  Visit PeeWee.Inc's Homepage
Dayve - i really do love you man

De Priofundus Calmo Ad Te Damine
Go to Top of Page

DJBBIZ
Junior Member

214 Posts

Posted - 12 March 2003 :  01:23:54  Show Profile  Visit DJBBIZ's Homepage
Mod works great...thanks...I wanted to eliminate Admins and Mods from the top posters so only members were included by adding to the WHERE clause:

strSql = strSql & "WHERE M.M_NAME <> 'n/a' AND M.M_LEVEL < 3 "

But this returns this eror:

Subscript out of range: '[number: 24]'

Does the fact that it finds 3 members that fit this profile cause the incrementing to get messed up?


"The difference between good ideas and good results is performance"
the management institute | tmiFinance | tmiCreative | ProfileOnDemand

Edited by - DJBBIZ on 12 March 2003 01:25:59
Go to Top of Page

OneWayMule
Dev. Team Member & Support Moderator

Austria
4969 Posts

Posted - 12 March 2003 :  01:28:29  Show Profile  Visit OneWayMule's Homepage  Send OneWayMule an ICQ Message
Nice work dayve. I've just tried it and it works great.

My MODs:
Birthdays - Custom Policy - F.A.Q. Administration - Forum Rules - Guestbook
Links Manager - MyOwnGoogle - Profile Views - Search Log - WebSearch

Useful stuff:
Forum and MOD Installation - MOD Installation Guide - Snitz v3.4.05 Readme - Free ASP Hosts - Support Snitz
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 12 March 2003 :  10:21:59  Show Profile  Visit dayve's Homepage
quote:
Originally posted by DJBBIZ


Does the fact that it finds 3 members that fit this profile cause the incrementing to get messed up?



yeah, I didn't put in an error trap. let me give that some thought. either that or get more members quickly!!! j/k

Go to Top of Page

xstream
Junior Member

242 Posts

Posted - 12 March 2003 :  14:33:30  Show Profile  Visit xstream's Homepage  Send xstream an AOL message  Send xstream an ICQ Message
Is there a version with all the changes?

This is awesome.

Xstream
Go to Top of Page

DJBBIZ
Junior Member

214 Posts

Posted - 13 March 2003 :  00:37:53  Show Profile  Visit DJBBIZ's Homepage
quote:
Originally posted by dayve

quote:
Originally posted by DJBBIZ


Does the fact that it finds 3 members that fit this profile cause the incrementing to get messed up?



yeah, I didn't put in an error trap. let me give that some thought. either that or get more members quickly!!! j/k



To clarify the error further, the forum is new but for University students we teach, and registration is not required so there is not a lot of members but there are more than 25...Many of the students, don't register or register and don't post, they just come there to get there resources or links...and leave. Just like the class room, they try not to make "Forum eye contact" and hope not to get called on! As such could the problem be the requirement that you have at least 25 actual posters? It works fine without the mLev=, and there are posters besides the admin and mods.


"The difference between good ideas and good results is performance"
the management institute | tmiFinance | tmiCreative | ProfileOnDemand
Go to Top of Page

terryp
Junior Member

United Kingdom
174 Posts

Posted - 13 March 2003 :  07:20:53  Show Profile  Visit terryp's Homepage
Ready to package this complete yet Dayve? Me wants it.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.42 seconds. Powered By: Snitz Forums 2000 Version 3.4.07