1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Resetting view count

Discussion in 'Styling and Customization Questions' started by s2kinteg9166, Mar 12, 2016.

  1. s2kinteg9166

    s2kinteg9166 Member

    I ran a query to update the thread view count to 0

    The database shows 0 but the front end now im seeing view count is the number of replies + 1

    Any ideas how i can get this to 0?

    The database shows the correct number
     
  2. wang

    wang Well-Known Member

    Code:
    UPDATE `xf_thread` SET view_count = 0;
    That sql query should reset all thread view counts to 0.

    Can you screenshot that part where thread view count is not correct?
     
  3. s2kinteg9166

    s2kinteg9166 Member

  4. wang

    wang Well-Known Member

    I have to ask, are you really sure that you excecuted that query in the database of your forum, and say, not in a database used for another forum?

    Can you please screenshot the view_count field for threads from phpmyadmin?
     
  5. s2kinteg9166

    s2kinteg9166 Member

  6. wang

    wang Well-Known Member

    And do thread views still appear like before?

    Can you please post here the link to your forum?
     
  7. s2kinteg9166

    s2kinteg9166 Member

  8. wang

    wang Well-Known Member

    Can you go to Crons in your Admin Panel and run this one, Update View Counters?
     
  9. s2kinteg9166

    s2kinteg9166 Member

    Just ran it says
    "
    Cron entry was run successfully.

    "
     
  10. wang

    wang Well-Known Member

    This is an odd issue. The only reasons that I can think of for this not working, is that either the query is not being run in the right database, or you have a third party add on that it is manipulating thread views.
     
  11. s2kinteg9166

    s2kinteg9166 Member

    Well the numbers are right in the database but front end shows a different number
     
  12. wang

    wang Well-Known Member

    Right, but if view count field for threads is 0 in the database, they should be 0 on front end too. That is why I suspect that the query maybe has not been excecuted in the right database.
     
  13. s2kinteg9166

    s2kinteg9166 Member

    I agree, but the fact the front end shows the view count as the reply count + 1 makes me think it has to do with how view counts are calculated.
     
  14. wang

    wang Well-Known Member

    View counts are separated from reply counts. Your situation is very strange.

    Can you check thread_list_item template, and see if you have this code there?

    HTML:
    <dl class="minor"><dt>{xen:phrase views}:</dt> <dd>{xen:if $thread.isRedirect, '&ndash;', {xen:number $thread.view_count}}</dd></dl>
    
    What add ons do you have installed? Can you list them here? Do you have custom made crons that perhaps manipulate thread views? Because this is not a default behavious of xenforo. There must be an outside thing causing this.
     
  15. s2kinteg9166

    s2kinteg9166 Member

  16. wang

    wang Well-Known Member

    Do you mind to give me access to your forum so I can have a look into this?

    I do not know if this is covered by the support policy of Xenforo, but you can open a Ticket at your Helpdesk, and maybe one of Xenforo 's Team members can look into this. Because this is a very odd issue.

    I will have to ask you again, are you 100% sure that you have run the query at the database where your forum is installed?
     
  17. s2kinteg9166

    s2kinteg9166 Member

    I submitted a ticket to support and they said theres no support =) since its not recommended.

    yes i only have one db and it works just the front end view is different. If you look in the DB it works how it should.

    when i use the batch update tool in xenforo the data is right as well. Its a front end view issue.
     
  18. Brogan

    Brogan XenForo Moderator Staff Member

    The view count is always going to be at least the post count (which is reply count +1).

    Check the model code.
     
    wang likes this.
  19. wang

    wang Well-Known Member

    You are correct sir. I thought that they would have been independent from each other. Is there any reason why it is being calculated like that?

    This is for the OP. If you do not want to be calculated like that, remove this code from the Thread.php file inside the Model folder.

    PHP:
    if ($thread['view_count'] <= $thread['reply_count'])
    {
            
    $thread['view_count'] = $thread['reply_count'] + 1;
    }
     
  20. Brogan

    Brogan XenForo Moderator Staff Member

    Logically, it is impossible for a thread to have 0 views.
    It has to have at least 1 view per post.
     

Share This Page