Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Active Topics
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Active Topics

 Post Reply Post Reply
Author
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Topic: Active Topics
    Posted: 14 September 2003 at 9:50pm
I'm back to revamping WWF to make it run more efficiently on my site. Made some changes that cut the processing time for the default page in half (from .4-.5 to .2-.23 seconds), part of that was removing the SQL call for the forum configuration (it won't change so why not have it hard coded into the page, one less SQL call).

I'm working on the active topics page and I noticed that the active topics page ignores the permissions table completely and relies soley on the default forum configuration. So if I have a forum viewable only to Moderators on my forum, then the active topics in that area don't show up for those that have access to those topics. Why is this? I hope to be able to write a SQL statement tonight (it's 11:45 pm my time) that will return the correct active topics for a user based upon all the user's permissions. I may post a mod, but my forum is so radically different from this board this point that the mod may not be very useful as I've consolidated cookies and gotten rid or session variables and hacked the code to pieces. :D
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2003 at 10:27pm
Well that was easier than I thought.
For those that are interested here's the SQL stored procedure. Note that rather that you have to pass the stored procedure a date and the Author_ID of the user. I'll be figuring out the date ASP side which will allow me to remove all the filters currently in the page. Note I also return all the category information so that I'm not making another call to the database later in order to get the category information.


CREATE PROCEDURE wwf_sp_ActiveTopics (
@AuthorID int,
@dteMinimum datetime
)
as
declare @GroupID int
set @GroupID = (select Group_ID from tblAuthorA where Author_ID=@AuthorID)

SELECT     dbo.tblCategory.Cat_ID AS Cat_ID,dbo.tblCategory.Cat_name AS Cat_name, dbo.tblForum.Forum_name AS Forum_name, dbo.tblForum.Password AS Password,
                          dbo.tblForum.Forum_code AS Forum_code, dbo.tblForum.[Read] AS [Read], dbo.tblTopic.*
FROM        dbo.tblCategory RIGHT OUTER JOIN
                          dbo.tblForum ON dbo.tblCategory.Cat_ID = dbo.tblForum.Cat_ID RIGHT OUTER JOIN
                          dbo.tblTopic ON dbo.tblForum.Forum_ID = dbo.tblTopic.Forum_ID
WHERE
     (tblForum.[Read] = 1 OR      (tblTopic.Forum_ID in (select Forum_ID from tblPermissions where Author_ID=@AuthorID or Group_ID = @GroupID and [Read]=1)))
     AND tblTopic.Last_entry_date >=@dteMinimum
ORDER BY
     tblCategory.Cat_order ASC, tblForum.Forum_Order ASC, tblTopic.Last_entry_date DESC;
GO

Maybe Borg will incorporate this into the active topics page in the next release (if he already hasn't).



Edited by ljamal
Back to Top
wistex View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 30 August 2003
Location: United States
Status: Offline
Points: 877
Post Options Post Options   Thanks (0) Thanks(0)   Quote wistex Quote  Post ReplyReply Direct Link To This Post Posted: 15 September 2003 at 10:30pm

Thanks!  I was looking for some way to make default.asp load faster.  Mine takes 4 seconds to fully load.  4 seconds is too long, quite frankly.  All the other pages load pretty fast.

What exactly to I have to move into default.asp to make it load faster?

I am using the SQL version.



Edited by wistex
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 15 September 2003 at 10:48pm
The biggest time hog for SQL users is the multiple trips to the database. It makes around 20 or so hits to the database, so if you can contract those 20 hits into fewer hits, that will drastically reduce your load speed. This is only something that should be tackled by someone with a fair amount of knowledge of stored procedures and ASP.

For the default page
I moved the common.asp stuff into a stored procedure with gets the user info and permissions and PM info and date formating. I hardcoded all the forum configuration information (because it's not going to change so I don't need the extra call to the database). That cut out about 4-5 calls to the database.
Moving to the page itself, I removed all the stats code from the bottom. I combined the forum and category query into one view of the forums with categories. I returned the permissions for the forum and the user's group and got the moderators and the last posts.
The first paragraph is stuck in one stored procedure and the second in another and they are both queried at one time. Those 2 stored procedures return 9 recordsets which are used to build the page.
Back to Top
ilnar View Drop Down
Newbie
Newbie


Joined: 02 October 2003
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote ilnar Quote  Post ReplyReply Direct Link To This Post Posted: 04 October 2003 at 1:58am

Originally posted by ljamal ljamal wrote:

WHERE
     (tblForum.[Read] = 1 OR      (tblTopic.Forum_ID in (select Forum_ID from tblPermissions where Author_ID=@AuthorID or Group_ID = @GroupID and [Read]=1)))
     AND tblTopic.Last_entry_date >=@dteMinimum

Why "tblForum.[Read] = 1" - [Read] in this context not permissions attribute, IMHO.

IMHO, right check "tblForum.[Hide] = 0"

Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post Posted: 04 October 2003 at 3:42am
Originally posted by ilnar ilnar wrote:

Originally posted by ljamal ljamal wrote:

WHERE
     (tblForum.[Read] = 1 OR      (tblTopic.Forum_ID in (select Forum_ID from tblPermissions where Author_ID=@AuthorID or Group_ID = @GroupID and [Read]=1)))
     AND tblTopic.Last_entry_date >=@dteMinimum

Why "tblForum.[Read] = 1" - [Read] in this context not permissions attribute, IMHO.

IMHO, right check "tblForum.[Hide] = 0"

You want to display only the topics the user can read, when tblForum.Hide is set to 1 that only tells the app to hide the forum IF tblForum.[Read] = 0 so that fact that Hide = 1 does not means that the user don't have access to the forum.

FeRnAN
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 04 October 2003 at 5:56am
All hide does is hide forums that the user does not have access to.

Forum.[Read] = 1 gets all the forums that the user has default access to.
select Forum_ID from tblPermissions where Author_ID=@AuthorID or Group_ID = @GroupID and [Read]=1 gets all the forums that that the user has special permissions to access.

However, I just noted that if you specifically EXCLUDE a user using the Permissions table, they will still have access to the forum via Active Topics so the additional modifier of AND NOT Forum.TableID in (select Forum_ID from tblPermissions where Author_ID=@AuthorID or Group_ID = @GroupID and [Read]=0) should be added to exclude the forum that the user does not have access to.
Back to Top
 Post Reply Post Reply

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.