Skip to content

Commit

Permalink
Rip out activity feed for now
Browse files Browse the repository at this point in the history
I found it would not be possible to display an activity feed due to the
event_log table not having enough data to display objects that were
changed. A true change log table would need to be created to have an
activity feed on the front page of BNETDocs.
  • Loading branch information
carlbennett committed Feb 11, 2019
1 parent 19345d7 commit 5720e8a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/controllers/EventLog/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function &run(Router &$router, View &$view, array &$args) {
if ($model->page > $model->pages) { $model->page = $model->pages; }

$model->events = Event::getAllEvents(
null,
$order,
$model->limit,
$model->limit * ( $model->page - 1 )
Expand Down
27 changes: 23 additions & 4 deletions src/libraries/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,17 @@ public function __construct( $data ) {
}

public static function &getAllEvents(
$order = null, $limit = null, $index = null
$filter_types = null, $order = null, $limit = null, $index = null
) {

if (empty($filter_types)) {
$where_clause = '';
} else {
$where_clause = 'WHERE `event_type_id` IN ('
. implode( ',', $filter_types ) . ')'
;
}

if (!(is_numeric($limit) || is_numeric($index))) {
$limit_clause = '';
} else if (!is_numeric($index)) {
Expand All @@ -49,7 +57,7 @@ public static function &getAllEvents(

if (empty($limit_clause)) {

$cache_key = 'bnetdocs-events';
$cache_key = 'bnetdocs-events-' . hash( 'md5', $where_clause );
$cache_val = Common::$cache->get( $cache_key );

if ( $cache_val !== false && !empty( $cache_val ) ) {
Expand Down Expand Up @@ -81,6 +89,7 @@ public static function &getAllEvents(
`meta_data`,
`user_id`
FROM `event_log`
' . $where_clause . '
ORDER BY
' . ($order ? '`' . $order[0] . '` ' . $order[1] . ',' : '') . '
`id` ' . ($order ? $order[1] : 'ASC') . ' ' . $limit_clause . ';'
Expand Down Expand Up @@ -118,14 +127,24 @@ public static function &getAllEvents(
return null;
}

public static function getEventCount() {
public static function getEventCount($filter_types = null) {
if (!isset(Common::$database)) {
Common::$database = DatabaseDriver::getDatabaseObject();
}

try {

$stmt = Common::$database->prepare('SELECT COUNT(*) FROM `event_log`;');
if (empty($filter_types)) {
$where_clause = '';
} else {
$where_clause = ' WHERE event_type_id IN ('
. implode( ',', $filter_types ) . ')'
;
}

$stmt = Common::$database->prepare(
'SELECT COUNT(*) FROM `event_log`' . $where_clause . ';'
);

if ( !$stmt->execute() ) {
throw new QueryException( 'Cannot query event count' );
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/EventTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace BNETDocs\Libraries;

use \SplEnum;

class EventTypes {

const LOG_NOTE = 0;
Expand Down
7 changes: 0 additions & 7 deletions src/templates/FrontPage.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ require("./header.inc.phtml");
<li>and <a href="<?php echo Common::relativeUrlToAbsolute('https://github.com/BNETDocs/bnetdocs-web/issues'); ?>">suggest improvements</a> to the site.</li>
</ul></p>
<p>Help our community and documentation grow! Receive recognition for your work on our <a href="<?php echo Common::relativeUrlToAbsolute('/credits'); ?>">contributors</a> page!</p>
</section>
</article>
<article>
<header>Activity Feed</header>
<section>
<p>Here's the latest of what's going on at BNETDocs.</p>
<?php include('./NYI.inc.phtml'); ?>
<hr/>
<p>
<a class="button" href="<?php echo Common::relativeUrlToAbsolute('/news'); ?>">Read News</a>
Expand Down

0 comments on commit 5720e8a

Please sign in to comment.