Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-08-2002, 10:19 AM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Last Viewed Date

How much of an extra server hit would it be to mark a thread with a last viewed date when somebody reads it?

I would love to be able to maintain this information, and then prune based on removing threads that have not been viewed in xx number of days.

Amy
Reply With Quote
  #2  
Old 07-08-2002, 11:39 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can add this information to the query that is already there, that updates the thread views.

Add a lastview field to the thread table, set it up like dateline field, and then in showthread.php replace this:
PHP Code:
if ($noshutdownfunc) {
  
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");
} else {
  
$shutdownqueries[]="UPDATE LOW_PRIORITY thread SET views=views+1 WHERE threadid='$threadid'";

With this:
PHP Code:
if ($noshutdownfunc) {
  
$DB_site->query("UPDATE thread SET views=views+1, lastview=".time()." WHERE threadid='$threadid'");
} else {
  
$shutdownqueries[]="UPDATE LOW_PRIORITY thread SET views=views+1, lastview=".time()." WHERE threadid='$threadid'";

Reply With Quote
  #3  
Old 07-08-2002, 11:47 AM
Birdie501's Avatar
Birdie501 Birdie501 is offline
 
Join Date: Dec 2001
Location: Germany
Posts: 272
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

and what about the server?
Reply With Quote
  #4  
Old 07-08-2002, 11:55 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What about it?
Reply With Quote
  #5  
Old 07-08-2002, 12:33 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you, Chen.

This means I just need to hack the prune routines a bit, and I should be good to go.

Amy
Reply With Quote
  #6  
Old 07-08-2002, 12:51 PM
Birdie501's Avatar
Birdie501 Birdie501 is offline
 
Join Date: Dec 2001
Location: Germany
Posts: 272
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by FireFly
What about it?
Forget it :-)
Reply With Quote
  #7  
Old 07-08-2002, 02:13 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here is the rest of what I conceived. I am not supporting this as a released hack because I am not set up to test it thorougly. Use at YOUR OWN RISK.
Find:
PHP Code:
doformheader("thread","pruneuser"); 
Paste before:

PHP Code:
  doformheader("thread","pruneviewed");
  
maketableheader("Prune by Date Last Viewed");
  
makeinputcode("Delete threads with last viewed before x days:<BR>(intensive if deleting a lot of threads)","daysdelete","0");
  
//makeforumchoosercode("Forum","forumid",-1,"All forums");
  
makeforumchooser("forumid",-1,-1,"","----- all -----","Forum:");
  
makeyesnocode("Include sub forums","subforums");
  
doformfooter("Prune"); 
Find:

PHP Code:
// ###################### Start Prune by date ####################### 
Paste before:

PHP Code:
// ###################### Start Prune by last viewed #######################
if ($action=="pruneviewed") {
  if (
$daysdelete=="") {
    echo 
"<p>Please enter an age of last view to delete</p>";
    exit;
  }

  if (
$confirm!=1) {

    if (
$forumid==-1) {
      
$forumtitle="all forums";
    } else {
      
$forum=$DB_site->query_first("SELECT title FROM forum WHERE forumid=$forumid");
      
$forumtitle="the \"$forum[title]\" forum";
      if (
$subforums) {
        
$forumtitle.=" and sub forums";
      }
    }

    
doformheader("thread","pruneviewed");
     
maketableheader("Prune All Threads Automatically");
     
makehiddencode("forumid""$forumid");
     
makehiddencode("daysdelete""$daysdelete");
     
makehiddencode("subforums""$subforums");
     
makehiddencode("confirm""1");
     
doformfooter("Click Here to Prune All Threads Automatically","",2);

     
doformheader("thread","prunedatevie");
     
maketableheader("Prune Threads Selectively");
     
makehiddencode("forumid""$forumid");
     
makehiddencode("daysdelete""$daysdelete");
     
makehiddencode("subforums""$subforums");
     
doformfooter("Click Here to Prune Threads Selectively","",2);

    
//<a 

href=\"thread.php?s=$session[sessionhash]&action=prunedatesel&forumid=$forumid&daysdelete=$daysdelete&subforums=$subforums\"><b>here</b></a> 

to select those to delete.</p>"
;
    exit;
  }

  if (
$forumid!=-1) {
    if (
$subforums) {
      
$forumcheck="(thread.forumid=$forumid OR INSTR(parentlist,',$forumid,')>0) AND ";
    } else {
      
$forumcheck="thread.forumid=$forumid AND ";
    }
  }

  
$datecut=time()-($daysdelete*86400);
  
$threads=$DB_site->query("SELECT threadid FROM thread LEFT JOIN forum USING (forumid) WHERE $forumcheck thread.lastview<=$datecut AND 

thread.sticky=0"
);
  while (
$thread=$DB_site->fetch_array($threads)) {
    
deletethread($thread[threadid],0);
  }

  echo 
"<p>Posts deleted successfully! It is recommended that you <a href=\"misc.php?s=$session[sessionhash]\">update counters</a> now.</p>";
}

// ###################### Start Prune by date selector #######################
if ($action=="prunedatevie") {

  
doformheader("thread","dopruneviewed");

  if (
$forumid!=-1) {
    if (
$subforums) {
      
$forumcheck="(thread.forumid=$forumid OR INSTR(parentlist,',$forumid,')>0) AND ";
    } else {
      
$forumcheck="thread.forumid=$forumid AND ";
    }
  }

  echo 
"<tr class='tblhead'><td><font size='1'><b><span class='tblhead'>Thread Title</span></b></font></td><td><font size='1'><b><span 

class='tblhead'>Delete?</span></b></font></td></tr>\n"
;

  
$datecut=time()-($daysdelete*86400);
  
$threads=$DB_site->query("SELECT threadid,thread.title,thread.replycount FROM thread LEFT JOIN forum USING (forumid) WHERE $forumcheck 

thread.lastview<=
$datecut ORDER BY thread.lastpost DESC");
  while (
$thread=$DB_site->fetch_array($threads)) {
    
makeyesnocode("<a href=\"../showthread.php?s=$session[sessionhash]&threadid=$thread[threadid]\" 

target=_blank>
$thread[title]($thread[replycount])</a>","delete[$thread[threadid]]",0);
  }

  
doformfooter("Submit - only click here if you are ABSOLUTELY certain");
}

// ###################### Start Prune by date selected #######################
if ($HTTP_POST_VARS['action']=="dopruneviewed") {

  echo 
"<p>Deleting...</p>";

  while (list(
$key,$val)=each($delete)) {
    if (
$val==1) {
      
deletethread($key,0);
    }
  }

  echo 
"<p>Threads deleted successfully! It is recommended that you <a href=\"misc.php?s=$session[sessionhash]\">update counters</a> 

now.</p>"
;

That's it. It seems to work on my board, but I have only pruned selectively and tested minimally. I will be very cautious using this for a while until it is well proven.

Amy
Reply With Quote
  #8  
Old 07-08-2002, 02:17 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

One other thing. I am going to set all my lastview amounts to yesterday's date with a single one-time query in phpmyadmin and then start counting from yesterday for prune purposes.

Amy
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:55 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04250 seconds
  • Memory Usage 2,289KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete