Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-14-2015, 05:05 AM
Chris.08i Chris.08i is offline
 
Join Date: Oct 2008
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Posts Per Week Statistic

Hello,

It's me again - so I'm looking to either create a plugin, or use whatever variables that are already available to somehow come up with a way to figure out a users post per week statistic.

I am not really sure how to go about this.

Any tips to point me in the right direction would be great.
Reply With Quote
  #2  
Old 12-14-2015, 01:43 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you are wanting to display this statistic on a user's profile page, then you could create a plugin as follows:

Product: vBulletin (or whatever product you wish this to be a part of)

Hook Location: member_build_blocks_start

Title: Compute Posts Per Week

Execution Order: 5

Plugin PHP Code:

PHP Code:
$prepared['postsperweek'] = number_format($userinfo['posts']/((TIMENOW $userinfo['joindate'])/(7*86400)), 2); 
Plugin is Active: Yes

In the PHP Plugin Code, we are creating the number as part of the $prepared array since it is already registered there, and then using the number_format function to round it off to 2 decimal places to match the posts per day.

Then, edit your "memberinfo_block_statistics" template by locating the code:

HTML Code:
	<dl class="blockrow stats">
		<dt>{vb:rawphrase posts_per_day}</dt>
		<dd> {vb:raw prepared.postsperday}</dd>
	</dl>
And below it add:

HTML Code:
	<dl class="blockrow stats">
		<dt>Posts Per Week</dt>
		<dd> {vb:raw prepared.postsperweek}</dd>
	</dl>
Reply With Quote
  #3  
Old 12-15-2015, 03:59 AM
Chris.08i Chris.08i is offline
 
Join Date: Oct 2008
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks again Mark. I actually have another question, but I will create another thread.

For this though - I actually wanted to calculate it on a weekly basis.

I made a new column in my user table, and added a hook to newpost_complete which +1 to the count. I then added a cron job to reset the count to 0 each week (based off of there having been activity in the account in the last week to cut down on database writes)
Reply With Quote
  #4  
Old 12-15-2015, 04:16 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you want a query that returns the number of posts made by a particular user during the last week, you could use:

PHP Code:
$posts_this_week $vbulletin->db->query_first("
    SELECT COUNT(*) AS post_count
    FROM " 
TABLE_PREFIX "post AS post
    WHERE userid = " 
$userinfo['userid'] . "
    AND dateline >= " 
. (TIMENOW 7*86400)
);

$prepared[poststhisweek] = $posts_this_week['post_count']; 
Then you could run this query once a week. If you want to run a query that counts the posts made by all users during the last week, let me know.
Reply With Quote
Благодарность от:
CAG CheechDogg
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:17 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03609 seconds
  • Memory Usage 2,201KB
  • 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
  • (2)bbcode_html
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (1)post_thanks_box_bit
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete