Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

August 12, 2022, 02:39:03 AM

Login with username, password and session length
Members
  • Total Members: 3842
  • Latest: Kokoro
Stats
  • Total Posts: 193479
  • Total Topics: 21088
  • Online today: 46
  • Online ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 1
Guests: 41
Total: 42

Author Topic: [Block] members with the most "posts per day"?  (Read 12733 times)

0 Members and 1 Guest are viewing this topic.

adirisman

  • Guest
[Block] members with the most "posts per day"?
« on: April 25, 2009, 04:41:25 AM »
Hi,

Is there any way to show 10 members with the most "posts per day" in a block?

thanks.
« Last Edit: April 27, 2009, 11:32:29 PM by G6 »

Offline G6Cad

  • Friends
  • *
  • Posts: 12643
    • FamiljeGodis
Re: Block: members with the most "posts per day"?
« Reply #1 on: April 25, 2009, 05:04:28 AM »
Did you check the block code and snippets board ?

JPDeni

  • Guest
Re: Block: members with the most "posts per day"?
« Reply #2 on: April 25, 2009, 12:46:47 PM »
I haven't seen anything like that before.

In answer to your question, yes, there is. It would be something like this:

Code: [Select]
global $db_prefix;
$result = db_query("
SELECT (posts / ( ( UNIX_TIMESTAMP( ) - dateRegistered ) / ( 3600 *24 ) )) AS ppd, realName
FROM {$db_prefix}members
ORDER BY ppd DESC
LIMIT 10", __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($result))
echo $row['realName'] . ' ' . $row['ppd'] . '<br />';
mysql_free_result($result);

This would go into a php block.
« Last Edit: June 14, 2009, 07:29:31 AM by JPDeni »

adirisman

  • Guest
Re: Block: members with the most "posts per day"?
« Reply #3 on: April 27, 2009, 10:45:29 PM »
wow.. thanks...

that works.

JPDeni

  • Guest
Re: [Block] members with the most "posts per day"?
« Reply #4 on: April 28, 2009, 06:21:05 AM »
Cool!  8)

That was a pretty easy one. It was just a matter of looking in the code to see how the posts per day were computed and then putting the same function in the query and letting MySQL do it. I learned something when doing it, too, because I'd never worked with a function in a query before. It opens up a lot of other possibilities.

This was one that was easy to test, too, so it wasn't nearly the problem that I have with other requests. I'm glad I was able to give you something you can use.  :)

alhaudhie

  • Guest
Re: [Block] members with the most "posts per day"?
« Reply #5 on: April 30, 2009, 10:20:08 AM »
how about top poster today.... with the number of posts?

JPDeni

  • Guest
Re: [Block] members with the most "posts per day"?
« Reply #6 on: April 30, 2009, 10:51:05 AM »
When does "today" start? GMT? Server time? Forum time? User's time?

There's just too many possibilities.

alhaudhie

  • Guest
Re: [Block] members with the most "posts per day"?
« Reply #7 on: April 30, 2009, 11:04:10 AM »
oh... tq for reply  :up: :up: ... but i thing a have got it in other topic like

Code: [Select]
global $db_prefix, $scripturl, $memberContext, $txt, $modSettings;
$maxlength=20;

// $starttime = strtotime('24 hours ago'); //posters laatste 24 uur
$starttime = mktime(0, 0, 0, date('m'), date('d'), date('Y')); //posters vandaag
$list_count = 10;

$poster = array();

$request = db_query("
SELECT  m.ID_MEMBER, COUNT(m.ID_MEMBER) as postCount
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
WHERE m.posterTime > " . $starttime . "
AND t.ID_TOPIC = m.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) &&

$modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
GROUP BY m.ID_MEMBER
ORDER BY postCount DESC LIMIT " . $list_count, __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($request))
{
    loadMemberData(array($row['ID_MEMBER']));
    loadMemberContext($row['ID_MEMBER']);
$membername = (strlen($memberContext[$row['ID_MEMBER']]['name']) > $maxlength) ?

substr($memberContext[$row['ID_MEMBER']]['name'],0,$maxlength) : $memberContext[$row['ID_MEMBER']]['name'];
$poster[$row['ID_MEMBER']] = array (
  'id' => $row['ID_MEMBER'],
  'count' => $row['postCount'],
  'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" title="' . $txt[92] . ' ' .

$memberContext[$row['ID_MEMBER']]['name'] . '">' . '<font color="' .

$memberContext[$row['ID_MEMBER']]['group_color'] . '">' . $membername . '</font>' . '</a>' );
}
mysql_free_result($request);

echo '<table width=100%>';
foreach($poster as $top_user)
{
echo '<tr>
      <td align="left" width=100%>' . $top_user['link'] . '</td>
      <td align="left">| '. $top_user['count'] . '</td>
      </tr>';
}
echo '</table>';

JPDeni

  • Guest
Re: [Block] members with the most "posts per day"?
« Reply #8 on: April 30, 2009, 11:49:02 AM »
That would be server time.

I guess you don't need the code, then, because already found it.

Offline Mick

  • Sr. Member
  • ****
  • Posts: 334
  • I use SMF 2.0.15
    • idesignSMF.com
Re: [Block] members with the most "posts per day"?
« Reply #9 on: April 30, 2009, 03:47:01 PM »
JPDeni,   its crazy how you can whip-up codes in a jiff.

Very cool.  Thanx.