• AspNetForum论坛整改:在论坛信息无法显示:浏览最多主题,回复最多的帖子……


    以前装了ASPNETFORUM中文版之后,发现论坛统计信息中在过去 3 天内: 浏览次数最多的主题是显示不出名称来,由于那时也没有想法说去修改程序,也就懒得去查找原因了

     这回由于整改。要对其它地方进行修改。所以也不得不对为什么显示不出主题的原因进行查找。花了N多小时(中间死机,聊天,找资料)发现问题的所有。

    修改存储过程:forums_system_UpdateSite

    将里面显示最多帖子的ID,浏览次数最多的主题及回复最多帖子的主题的ID的中将jP.[View] = 0x01 AND去除。原因我也无法找到,只是在forums_Threads中我无法找到.[View] ,如果存在这条件,语句永远是不成立的。





    CREATE PROCEDURE forums_system_UpdateSite 
    (
        @UpdateUserPostRank 
    bit = 1,
        @UpdateMostActiveUserList 
    bit = 1
    )
    AS
        
    -- Get summary information - Total Users, Total Posts, TotalTopics, DaysPosts, and DaysTopics
        DECLARE @LastDateTimeUpdate datetime
        
    DECLARE @TotalUsers int
        
    DECLARE @TotalPosts int
        
    DECLARE @TotalTopics int
        
    DECLARE @TotalModerators int
        
    DECLARE @TotalModeratedPosts int
        
    DECLARE @NewThreadsInPast24Hours int
        
    DECLARE @NewPostsInPast24Hours int
        
    DECLARE @NewUsersInPast24Hours int
        
    DECLARE @MostViewsPostID int--浏览次数最多的主题
        DECLARE @MostActivePostID int--最多回复的主题
        DECLARE @MostReadPostID int--浏览次数最多的帖子
        DECLARE @TotalAnonymousUsers int
        
    DECLARE @NewestUserID int--最新注册用户ID
        DECLARE @MostActiveUserID int

        
    SET NOCOUNT ON

        
    SET @LastDateTimeUpdate = ISNULL
                        (
                            
    SELECT TOP 1
                                DateCreated 
                            
    FROM 
                                forums_statistics_Site
                        ), 
    '1/1/1979 12:00:00')

        
    -- Reset top posters
        IF @UpdateUserPostRank = 1
            
    exec forums_system_UpdateUserPostRank

        
    IF @UpdateMostActiveUserList = 1
            
    exec forums_system_UpdateMostActiveUsers

        
    -- Total Anonymous Users
        -- ***********************************************
        SET @TotalAnonymousUsers = ISNULL
                        (
                            
    SELECT 
                                
    COUNT(UserID) 
                            
    FROM 
                                forums_AnonymousUsers
                        ), 
    0 )

        
    -- Total Moderators, for this site only
        -- ***********************************************
        SET @TotalModerators = ISNULL(
                        (
                            
    SELECT 
                                
    COUNT(jUR.UserID) 
                            
    FROM 
                                forums_UsersInRoles jUR
                                
    JOIN forums_Roles jR ON jR.RoleID = jUR.RoleID
                            
    WHERE 
                                jUR.RoleID 
    = 4
                        ), 
    0)

        
    -- Total Moderated Posts
        -- ***********************************************
        SET @TotalModeratedPosts = ISNULL
                        (
                            
    SELECT 
                                
    COUNT(ModerationAction) 
                            
    FROM 
                                forums_ModerationAudit 
                            
    WHERE 
                                ModeratedOn 
    >= @LastDateTimeUpdate
                        ), 
    0 )

        
    -- Most "Viewed" thread, by grabbing the first post
        -- ***********************************************
        SET @MostViewsPostID = ISNULL(
                        (
                            
    SELECT TOP 1 
                                jP1.PostID
                            
    FROM 
                                forums_Threads jT
                                
    JOIN forums_Posts jP1 ON jP1.ThreadID = jT.ThreadID
                                
    JOIN forums_ForumPermissions jP ON jP.ForumID = jT.ForumID
                            
    WHERE 
                                jP.RoleID 
    = 0 AND--jP.[View] = 0x01 AND                            
                                jT.ThreadDate > DateAdd(d, -3GetDate()) AND
                                jP1.IsApproved 
    = 1 AND
                                jT.ForumID 
    > 4        -- excluding PM and hidden forums
                            ORDER BY 
                                jT.TotalViews 
    DESC
                        ), 
    0)


        
    -- Most "Active" Thread, by grabbing the first post
        -- ***********************************************
        SET @MostActivePostID = ISNULL(
                        (
                            
    SELECT TOP 1 
                                jP1.PostID
                            
    FROM 
                                forums_Threads jT
                                
    JOIN forums_Posts jP1 ON jP1.ThreadID = jT.ThreadID
                                
    JOIN forums_ForumPermissions jP ON jP.ForumID = jT.ForumID
                            
    WHERE 
                                jP.RoleID 
    = 0 AND--jP.[View] = 0x01 AND                            
                                jT.ThreadDate > DateAdd(d, -3GetDate()) AND
                                jP1.IsApproved 
    = 1 AND
                                jT.ForumID 
    > 4        -- excluding PM and hidden forums
                            ORDER BY 
                                jT.TotalReplies 
    DESC
                        ), 
    0)

        
    -- Most "Read" thread, by grabbing the first post
        -- ***********************************************
        SET @MostReadPostID = ISNULL(
                        (
                            
    SELECT TOP 1 
                                jP1.PostID
                            
    FROM 
                                forums_Threads jT
                                
    JOIN forums_Posts jP1 ON jP1.ThreadID = jT.ThreadID
                                
    JOIN forums_ForumPermissions jP ON jP.ForumID = jT.ForumID
                            
    WHERE 
                                jP.RoleID 
    = 0 AND--jP.[View] = 0x01 AND                            
                                jT.ThreadDate > DateAdd(d, -3GetDate()) AND
                                jP1.IsApproved 
    = 1 AND
                                jT.ForumID 
    > 4        -- excluding PM and hidden forums
                            ORDER BY 
                                ( 
    SELECT count(jTR.ThreadID) FROM forums_ThreadsRead jTR WHERE jP1.ThreadID = jTR.ThreadID ) DESC
                        ), 
    0)


        
    -- Most active user
        -- ***********************************************
        SET @MostActiveUserID = ISNULL(
                        (
                            
    SELECT TOP 1 
                                jU.UserID

                            
    FROM 
                                forums_Users jU
                                
    JOIN forums_UserProfile jP ON jP.UserID = jU.UserID
                            
    WHERE
                                jP.EnableDisplayInMemberList 
    = 1
                            
    ORDER BY 
                                jP.TotalPosts 
    DESC
                        ), 
    0)
        
    -- Newest user
        -- ***********************************************
        SET @NewestUserID = ISNULL(
                        (
                            
    SELECT TOP 1 
                                 jU.UserID
                            
    FROM 
                                forums_Users jU
                                
    JOIN forums_UserProfile jP ON jP.UserID = jU.UserID
                            
    WHERE
                                jP.EnableDisplayInMemberList 
    = 1 AND
                                jU.UserAccountStatus 
    = 1
                            
    ORDER BY 
                                jU.DateCreated 
    DESC
                        ), 
    0)


        
    -- Total Users
        -- ***********************************************
        SET @TotalUsers = ISNULL
                        (
                            
    SELECT 
                                
    COUNT(UserID) 
                            
    FROM 
                                forums_UserProfile 
                            
    WHERE 
                                EnableDisplayInMemberList 
    = 1
                        ) ,
    0


        
    -- Total Posts
        -- ***********************************************
        SET @TotalPosts =     ISNULL
                        (
                            
    SELECT TOP 1 
                                TotalPosts 
                            
    FROM 
                                forums_statistics_Site
                        ), 
    0+
                     
    ISNULL
                        (
                            
    SELECT 
                                
    COUNT(PostID) 
                            
    FROM 
                                forums_Posts 
                            
    WHERE 
                                ForumID 
    > 4 AND 
                            PostDate 
    >= @LastDateTimeUpdate
                        ), 
    0)
        
    IF @TotalPosts = 0
        
    BEGIN
            
    -- there was no previous count.  this is mainly for clean installs
            SET @TotalPosts = (SELECT COUNT(PostID) FROM forums_Posts WHERE ForumID > 4)
        
    END


        
    -- Total Topics
        -- ***********************************************
        SET @TotalTopics =     ISNULL
                        (
                            
    SELECT TOP 1 
                                TotalTopics 
                            
    FROM 
                                forums_statistics_Site
                        ), 
    0+ 
                    
    ISNULL
                        (
                            
    SELECT 
                                
    COUNT(ThreadID) 
                            
    FROM 
                                forums_Threads 
                            
    WHERE 
                                ForumID 
    > 4 AND 
                                ThreadDate 
    >= @LastDateTimeUpdate
                        ), 
    0)
        
    IF @TotalTopics = 0
        
    BEGIN
            
    -- there was no previous count.  this is mainly for clean installs
            SET @TotalTopics = (SELECT COUNT(ThreadID) FROM forums_Threads WHERE ForumID > 4)
        
    END

        
    -- Total Posts in past 24 hours
        -- ***********************************************
        SET @NewPostsInPast24Hours = ISNULL
                        (
    SELECT COUNT(PostID) FROM forums_Posts WHERE ForumID > 4 And PostDate > DATEADD(dd,-1,getdate())
                        ), 
    0)

        
    -- Total Users in past 24 hours
        -- ***********************************************
        SET @NewUsersInPast24Hours = ISNULL(
                            (
    SELECT COUNT(UserID) FROM forums_Users WHERE UserID > 0 And DateCreated > DATEADD(dd,-1,getdate())
                        ), 
    0)


        
    -- Total Topics in past 24 hours
        -- ***********************************************
        SET @NewThreadsInPast24Hours = ISNULL(
                            (
    SELECT COUNT(ThreadID) FROM forums_Threads WHERE ForumID > 4 AND PostDate > DATEADD(dd,-1,getdate())
                        ), 
    0)

        
    INSERT INTO forums_statistics_Site
        
    SELECT 
            DateCreated 
    = GetDate(),
            TotalUsers 
    = @TotalUsers,
            TotalPosts 
    = @TotalPosts,
            TotalModerators 
    = @TotalModerators,
            TotalModeratedPosts 
    = @TotalModeratedPosts,
            TotalAnonymousUsers 
    = @TotalAnonymousUsers,
            TotalTopics 
    = @TotalTopics,
            DaysPosts 
    = @NewPostsInPast24Hours, -- TODO remove
            DaysTopics = @NewThreadsInPast24Hours, -- TODO remove
            NewPostsInPast24Hours = @NewPostsInPast24Hours,
            NewThreadsInPast24Hours 
    = @NewThreadsInPast24Hours,
            NewUsersInPast24Hours 
    = @NewUsersInPast24Hours,
            MostViewsPostID 
    = @MostViewsPostID,
            MostActivePostID 
    = @MostActivePostID,
            MostActiveUserID 
    = @MostActiveUserID,
            MostReadPostID 
    = @MostReadPostID,
            NewestUserID 
    = @NewestUserID


        
    SET NOCOUNT OFF
    GO
  • 相关阅读:
    JS保留小数点(四舍五入、四舍六入)实例
    HTML5 本地存储 localStorage、sessionStorage 的遍历、存储大小限制处理
    TCP/IP 网络编程(五)
    【IOS】mac终端运行.sh文件总是提示permission denied
    一扫天下——ZXing使用全解析
    《学习bash》笔记--进程处理
    VB断点调试
    poj 2506 Tiling(java解法)
    策略模式实战之优惠方式
    HTML 5 音频Audio
  • 原文地址:https://www.cnblogs.com/wish/p/80714.html
Copyright © 2020-2023  润新知