save percentage deleted posts/user - Postet den (1587 Views)
Senior Member
tribaliztic
Innlegg: 1532
1532
I saw a function on another forum that I would like to have... In all users profiles there was a percentage of how many post that had been deleted of the total post count on that user. I did a brain fart and had a quick look at pop_delete.asp. Is it as simple as adding this (please check the code for errors...) to pop_delete.asp to add "1" to M_DELPOST for the user that did the post/reply?
Under case "DeleteReply":

strSql = " UPDATE " & strMemberTablePrefix & "MEMBERS M" & _
"SET M.M_DELPOST = M.M_DELPOST + 1 "" & _
" WHERE M.MEMBER_ID = T.R_AUTHOR "

my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords

Under case "DeleteTopic":

strSql = " UPDATE " & strMemberTablePrefix & "MEMBERS M" & _
"SET M.M_DELPOST = M.M_DELPOST + 1 "" & _
" WHERE M.MEMBER_ID = T.R_AUTHOR "

my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords

Then just get that figure from the db and run it against total post count on the user and show the percentage in his/her profile.
Am I totally in the blue here? =)<
/Tribaliztic
- www.gotlandrace.se -
   
 Sidestørrelse 
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
It can be done without the need for an additional field; grab the number of posts a member has made from the TOPICS and REPLY tables, subtract that from M_POSTS and use the resulting figure to calculate your percentage. The drawback to this solution is that it requires an extra database hit.
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Postet den
Senior Member
tribaliztic
Innlegg: 1532
1532
It would only be used when viewing a profile so one extra hit wouldn't be that much of a problem.
So, something like:

COUNT("SELECT TOPICS FROM FORUM_TOPICS WHERE T_AUTHOR = ppMEMBER_ID" + "SELECT REPLIES FROM FORUM_REPLIES WHERE R_AUTHOR = ppMEMBER_ID") AS MEMBER_POST_COUNT
to count the number of posts?
Then like:
COUNT("M_POSTS - MEMBER_POST_COUNT") AS MEMBER_POST_PERCENTAGE

I have no clue how the syntax should be, I'm just having another brainfart..
(I really like that word =))
<
/Tribaliztic
- www.gotlandrace.se -
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
What database are you using again so's I can give you the necessary code?
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Postet den
Senior Member
tribaliztic
Innlegg: 1532
1532
MySQL, sorry =)
<
/Tribaliztic
- www.gotlandrace.se -
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
You don't know what version, do you? Going to try and do it with a nested query but older versions of MySQL don't support them.
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Postet den
Senior Member
tribaliztic
Innlegg: 1532
1532
DBMS Name MySQL
DBMS Version 4.0.20a-nt

I suppose this is the mysql version, found it in admin home under "server information". <
/Tribaliztic
- www.gotlandrace.se -
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
Hmm ... think that version should support nested queries so give the following a try:
Code:
set rscount=my_conn.execute("SELECT COUNT(*) AS inttcount, (SELECT COUNT(*) AS intrcount FROM "&strTablePrefix&"REPLY WHERE R_AUTHOR="&ppMember_ID&") FROM "&strTablePrefix&"TOPICS WHERE T_AUTHOR="&ppMember_ID)
intpcount=clng(rscount("inttcount"))+clng(rs("intrcount"))
rscount.close
set rscount=nothing
intdpercentage=abs(round(((intTotalMemberPosts-intpcount)/intTotalMemberPosts)*100))
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Postet den
Senior Member
tribaliztic
Innlegg: 1532
1532
heh, that query looks more cool than mine ;)

Thanks alot! I'll give it a try! <
/Tribaliztic
- www.gotlandrace.se -
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
You're welcome smile
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Postet den
Senior Member
tribaliztic
Innlegg: 1532
1532
Oops, I got this:

Microsoft OLE DB Provider for ODBC Drivers fel '80040e14'
[MySQL][ODBC 3.51 Driver][mysqld-4.0.20a-nt]You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT COUNT(*) AS intrcount FROM FORUM_REPLY WHERE R_AUTHOR=50

/pop_profile.asp, line 839

also, this won't count archived posts I suppose? <
/Tribaliztic
- www.gotlandrace.se -
Du må legge inn en melding