Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 02-01-2006, 07:28 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Recently Viewed (Hack in Progress)

After lurking around sitepoint today, I thought I would create a hack much like they have. "Recently Viewed". The first thing I did is search vB.org to see if it was recently released, or released in the past. I did find a few request for this, but no hack has ever been acually released to the public.

So I started thinking how I can create this hack the best way possiable. The first thing that came into mind is create a new table called "recentlyviewed" with the following information.

'recentlyviewed' Table
  • userid
    The userid of the user viewing the thread
  • threadid
    The threadid of the thead the user is viewing
  • dateline
    The date/time user viewed thread. (TIMENOW)

This means the 1 query will be added on the showthread.php page (per user). Now this method can instantly start filling the "recentlyviewed" table with large boards; Seeing as showthread.php is the mosted used file IMHO. So I thought, lets only keep 5 listing per userid.


Keep only 5 listing in database (per userid)
This would be done using the global.php file...

Scenario:
User has viewed 10 threads (according to the recentlyviewed table). Delete the oldest 5.

Conditions before sql execution:

Code:
	
SQL = count total threads where userid = userid

if (user has more the 5 viewed threads)
{
        Delete the oldest threads viewed, keeping the latest 5
}
else
{
        exit();
}
Now please note that I havn't even started coding this. I just started thinking about it and wanted to get in on paper, and also hear what a few other coders input before I start. So, if you have a better method, please explain. If not, how can I delete the oldest threads viewed, keeping the latest 5? Thanks everyone!

Also, I will publicly release this once this is finished...
Reply With Quote
  #2  
Old 02-01-2006, 07:32 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am a bit dense today. Where is this meant to show? Does it show recently viewed posts by anyone or does it show the user the posts they recently viewed?
Reply With Quote
  #3  
Old 02-01-2006, 07:38 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This will show the latest 5 threads (Recently Viewed) per logged in user. This can be shown anywhere one would want really. I will code the public version so its shown on the forumhome page. My personal version will be shown on my cutom portal I'm creating.

I should also note that even though the Recently Viewed table only has 3 rows, I will be able to get the rest of the information using JOINs in the SQL. In case anyone was wondering...
Reply With Quote
  #4  
Old 02-01-2006, 07:40 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Gotcha. I think if I were doing this, I would try to hook into how vbulletin is recording what threads the user has viewed. It tracks them already by user for the getnew to work properly. So, obviously, the info about the threads viewed is stored somewhere. It's just a matter of finding it and pulling it.
Reply With Quote
  #5  
Old 02-01-2006, 07:51 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yea, though how vBulletin determins which post have been read, is beyond me. I don't think I will beable to hook into there method though. I can't seem to understand/find how they record which post have been read/unread. I would guess its a combination of the post dateline, vistlog, and users last activity. I just don't see a table that would keep track of this all..
Reply With Quote
  #6  
Old 02-01-2006, 07:56 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

From what I'm seeing, it looks like it's in a cookie.

in showthread.php, you'll see,
Code:
$threadview = intval(fetch_bbarray_cookie('thread_lastview', $thread['threadid']));
and
Code:
if ($displayed_dateline <= $threadview)
			{
				$updatethreadcookie = true;
			}
I found this by going to the forum settings, seeing that jelsoft called it thread marking and searching showthread for marking and then following the code.
Reply With Quote
  #7  
Old 02-01-2006, 08:06 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Adding to the table could be done with a shutdown query.

I wouldn't do any cleaning on pageloads. Better create a scheduled task for that. Clean the table by either maximum X rows/user, or by dateline.
Reply With Quote
  #8  
Old 02-01-2006, 08:21 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I was thinking what Marco said. a vBcron every X mins. The thing that stoped me was how can I clean the table out per userid? Wouldn't be able to use WHERE userid = $vbulletin->userinfo['userid'] since its running as a cron...

I would have to get every userid from the users table and during the while statement I could clean up the table, but that seems like alot of work for a cron right?
Reply With Quote
  #9  
Old 02-01-2006, 08:55 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

A lot of cronjobs perform actions on all users. All it would probably take is a single wellformed SQL-statement.



Cleaning up once a day would be enough i think, maybe once an hour.
Reply With Quote
  #10  
Old 02-01-2006, 09:15 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Marco, I'll prolly end up doing it that way and will release to the public when finished.
Reply With Quote
Reply

Thread Tools
Display Modes

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 08:12 PM.


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.04174 seconds
  • Memory Usage 2,247KB
  • Queries Executed 11 (?)
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
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete