Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - REQ: Update Members Post Counts
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

REQ: Update Members Post Counts

 Post Reply Post Reply Page  123>
Author
MortiOli View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 May 2002
Location: United Kingdom
Status: Offline
Points: 514
Post Options Post Options   Thanks (0) Thanks(0)   Quote MortiOli Quote  Post ReplyReply Direct Link To This Post Topic: REQ: Update Members Post Counts
    Posted: 08 October 2006 at 2:01am
I understand there's the tool to resync topic and post counts, but am I right in saying that this is just counts for each forum?
 
The reason I ask is that I have a lot of members with minus post counts (no idea why...probably from the Snitz forum I had a while back).  I also have a moderator who thought it would be amusing to change their post count to ~10 times the amount they have.
 
Is there anyway to run a script to update members post counts?
 
Cheers!
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 08 October 2006 at 3:03pm
Sorry there isn't
Back to Top
MortiOli View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 May 2002
Location: United Kingdom
Status: Offline
Points: 514
Post Options Post Options   Thanks (0) Thanks(0)   Quote MortiOli Quote  Post ReplyReply Direct Link To This Post Posted: 05 November 2006 at 12:17am
Any chance this could be moved to the mod forum, as a request please?

Edited by MortiOli - 05 November 2006 at 12:17am
Back to Top
MortiOli View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 May 2002
Location: United Kingdom
Status: Offline
Points: 514
Post Options Post Options   Thanks (0) Thanks(0)   Quote MortiOli Quote  Post ReplyReply Direct Link To This Post Posted: 18 November 2006 at 10:28am
Anyone interested in creating this please?
Back to Top
Ali Bilgrami View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 April 2005
Location: Pakistan
Status: Offline
Points: 492
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ali Bilgrami Quote  Post ReplyReply Direct Link To This Post Posted: 18 November 2006 at 6:15pm
well you can run an SQL query on your DB with some criteria to increase the no of posts times X or +X...
Lets!
Back to Top
MortiOli View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 May 2002
Location: United Kingdom
Status: Offline
Points: 514
Post Options Post Options   Thanks (0) Thanks(0)   Quote MortiOli Quote  Post ReplyReply Direct Link To This Post Posted: 19 November 2006 at 12:40pm

I don't really want to increase / decrease people's posts by X amount, but I want to run something that counts everyone's posts and topics, then updates their member profile to reflect their true post count.

Back to Top
MortiOli View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 May 2002
Location: United Kingdom
Status: Offline
Points: 514
Post Options Post Options   Thanks (0) Thanks(0)   Quote MortiOli Quote  Post ReplyReply Direct Link To This Post Posted: 08 January 2007 at 9:03pm
Following on from this...
 
I remembered I had a script to do exactly this on Snitz forums.  Basically you ran the page and it went off, counted up all topics created by each person, and all replies made that person.  Obviously the end result was there post count, which it updated their profile with.
 
I've tried to go through it and update it to reflect WWF tables etc, but I've hit a dead end with some of them.  If someone could look at what I have and help out, that would be brilliant;
 
<!--#INCLUDE FILE="config.asp" -->
<!--#INCLUDE FILE="inc_func_common.asp" -->
<%
Server.ScriptTimeOut = 180 ' drv: Set to 3 minutes or set higher if needed. I have no idea.
set my_Conn = Server.CreateObject("ADODB.Connection")
my_Conn.Open strConnString
Call GetMembers()
my_Conn.Close
set my_Conn = nothing

Sub GetMembers()
  dim strSql, rs
  strSql = "SELECT " & strDbTable & "Author.Author_ID, " &_
   strDbTable & "Author.No_of_posts, " &_
   strDbTable & "Author.Username " &_
   " FROM " &  strDbTable & "Author " &_
   " WHERE " & strDbTable & "Author.No_of_posts > 0 " &_
   " ORDER BY " & strDbTable & "Author.Author_ID;"
  set rs = Server.CreateObject("ADODB.Recordset")
  rs.open  strSql,  my_Conn
  response.write("<table cellpadding=""2"" cellspacing=""0"" border=""1"">" & vbCrLf &_
   "<tr valign=""bottom"" align=""center""><td align=""left""><b>Member's Name</b></td><td><b>M_Post<br>Count</b></td><td><b>Record<br>Count</b></td></tr>" & vbCrLf)
  If not (rs.EOF or rs.BOF) then  '## No replies found in DB
   do until rs.EOF
    response.write("<tr><td><b>" & rs.Fields("Username").Value & "</b></td><td align=""right"">" & rs.Fields("No_of_posts").Value & "</td><td align=""right"">")
    if (rs.Fields("No_of_posts").Value > 0) then Call GetPosts(rs.Fields("Author_ID").Value,rs.Fields("No_of_posts").Value)
    response.write("</td></tr>" & vbCrLf)
    rs.MoveNext
   loop
  End If
  response.write("</table>")
  rs.close
  set rs = nothing
End Sub
Sub GetPosts(intMemberID,intPostCount)
  dim strSql, rs, memberpostcount
  memberpostcount = intPostCount
  strSql = "(SELECT " & strDbTable & "Author.Author_ID, " &_
   strTablePrefix & "Topic.Topic_ID, " &_
   " 0 AS REPLY_ID, " &_
   strTablePrefix & "Topic.T_DATE AS R_DATE " &_
   " FROM " & strDbTable & "Author LEFT JOIN " & strTablePrefix & "Topic ON " &_
   strDbTable & "Author.Author_ID = " & strTablePrefix & "Topic.Start_Thread_ID " &_
   " WHERE (((" & strDbTable & "Author.Author_ID)=" & intMemberID & "))) UNION ALL " &_
   " (SELECT " & strDbTable & "Author.Author_ID, " &_
   strTablePrefix & "REPLY.Topic_ID, " &_
   strTablePrefix & "REPLY.REPLY_ID, " &_
   strTablePrefix & "REPLY.R_DATE " &_
   " FROM " & strDbTable & "Author LEFT JOIN " & strTablePrefix & "REPLY ON " &_
   strDbTable & "Author.Author_ID = " & strTablePrefix & "REPLY.R_AUTHOR " &_
   " WHERE (((" & strDbTable & "Author.Author_ID)=" & intMemberID & "))) " &_
   " ORDER BY R_DATE DESC;"
  set rs = Server.CreateObject("ADODB.Recordset")
  'rs.cachesize = strPageSize
  rs.open  strSql,  my_Conn, 3
  If not (rs.EOF or rs.BOF) then  '## No replies found in DB
   rs.movefirst
   response.write(rs.Recordcount)
   do until rs.EOF
    If (rs.Fields("REPLY_ID").Value > 0) Then
     Call UpdateReply(rs.Fields("REPLY_ID").Value,memberpostcount)
    Else
     If (rs.Fields("Topic_ID").Value > 0) Then Call UpdateTopic(rs.Fields("Topic_ID").Value,memberpostcount)
    End If
    ' drv: subtract one from post count
    If (memberpostcount > 0) then memberpostcount = memberpostcount - 1
    rs.MoveNext
   loop
  End If
  rs.close
  set rs = nothing
End Sub
Sub UpdateReply(intReplyID,intMemberPostCount)
 dim strSql
 '## Forum_SQL
 strSql = "UPDATE " & strTablePrefix & "REPLY " &_
  " SET " & strTablePrefix & "REPLY.R_POSTS = " & intMemberPostCount & " " &_
  " WHERE (" & strTablePrefix & "REPLY.REPLY_ID = " & intReplyID & ");"
 my_conn.Execute (strSql)
End Sub
Sub UpdateTopic(intTopicID,intMemberPostCount)
 dim strSql
 '## Forum_SQL
 strSql = "UPDATE " & strTablePrefix & "Topic " &_
  " SET " & strTablePrefix & "Topic.T_POSTS = " & intMemberPostCount & " " &_
  " WHERE (" & strTablePrefix & "Topic.Topic_ID = " & intTopicID & ");"
 my_conn.Execute (strSql)
End Sub
%>
 
Many thanks!
Back to Top
MortiOli View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 May 2002
Location: United Kingdom
Status: Offline
Points: 514
Post Options Post Options   Thanks (0) Thanks(0)   Quote MortiOli Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2007 at 6:04pm

Using the above as an idea, would someone be able to help me in coding an ASP page to do the following;

 - Count all posts for each user
 - Update each users No_of_Posts depending on the above
 
I've been running some queries on my database, and found that my forum and database says 126,456 posts, however, running a SUM on all users post counts, shows 148,596 - a difference of 22,140 between the actual count and members profiles.
 
Not too sure where this difference has occurred (maybe during my Snitz conversion), but running a search query on this forum shows me as having posted 212 posts, but my user profile shows 259...?  Strange.  Maybe posts don't always update with deletions etc?
Back to Top
 Post Reply Post Reply Page  123>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.