From 558152790d4931d7e7de1ddfed9c79527e5f665b Mon Sep 17 00:00:00 2001 From: 8n-tech <8n-tech@users.noreply.github.com> Date: Sun, 19 Apr 2015 23:00:39 +1000 Subject: [PATCH] More board directory stuff. #456 - Fixed issue where the CLI was generating the wrong index. #456 - Fixed issue where the user was requesting 100% of the boards on pagination. #456 - Fixed issue where board active users tracked the last hour and not the last 72 hours. Signed-off-by: 8n-tech <8n-tech@users.noreply.github.com> --- board-search.php | 14 ++++++-------- boards.php | 7 +++++-- inc/functions.php | 13 ++----------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/board-search.php b/board-search.php index b573edd1..5d51134b 100644 --- a/board-search.php +++ b/board-search.php @@ -200,16 +200,14 @@ array_multisort( ); if (php_sapi_name() == 'cli') { - $boardLimit = $search['index'] ? 50 : 100; - - $response['omitted'] = count( $response['boards'] ) - $boardLimit; - $response['omitted'] = $response['omitted'] < 0 ? 0 : $response['omitted']; - $response['boards'] = array_splice( $response['boards'], $search['page'], $boardLimit ); -} -else { - $response['omitted'] = 0; + $response['boardsFull'] = $response['boards']; } +$boardLimit = $search['index'] ? 50 : 100; + +$response['omitted'] = count( $response['boards'] ) - $boardLimit; +$response['omitted'] = $response['omitted'] < 0 ? 0 : $response['omitted']; +$response['boards'] = array_splice( $response['boards'], $search['page'], $boardLimit ); $response['order'] = array_keys( $response['boards'] ); diff --git a/boards.php b/boards.php index 600951d4..72d1ea33 100644 --- a/boards.php +++ b/boards.php @@ -94,13 +94,16 @@ $pageHTML = Element("page.html", array( // We only want to cache if this is not a dynamic form request. // Otherwise, our information will be skewed by the search criteria. -if (count($_GET) == 0) { +if (php_sapi_name() == 'cli') { // Preserves the JSON output format of [{board},{board}]. - $nonAssociativeBoardList = array_values($boards); + $nonAssociativeBoardList = array_values($response['boardsFull']); file_write("boards.html", $pageHTML); file_write("boards.json", json_encode($nonAssociativeBoardList)); file_write("boards-top20.json", json_encode(array_splice($nonAssociativeBoardList, 0, 48))); + + echo "The board directories have regenerated."; + exit; } echo $pageHTML; \ No newline at end of file diff --git a/inc/functions.php b/inc/functions.php index 1d5f8216..4c16f065 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -875,13 +875,6 @@ function fetchBoardActivity( array $uris = array(), $forTime = false, $detailed foreach ($bsResult as $bsRow) { // Do we need to define the arrays for this URI? if (!isset($boardActivity['active'][$bsRow['stat_uri']])) { - if ($bsRow['stat_hour'] == $forHour) { - $boardActivity['active'][$bsRow['stat_uri']] = unserialize( $bsRow['author_ip_array'] ); - } - else { - $boardActivity['active'][$bsRow['stat_uri']] = array(); - } - if ($bsRow['stat_hour'] <= $forHour && $bsRow['stat_hour'] >= $yesterHour) { $boardActivity['today'][$bsRow['stat_uri']] = $bsRow['post_count']; } @@ -889,17 +882,15 @@ function fetchBoardActivity( array $uris = array(), $forTime = false, $detailed $boardActivity['today'][$bsRow['stat_uri']] = 0; } + $boardActivity['active'][$bsRow['stat_uri']] = unserialize( $bsRow['author_ip_array'] ); $boardActivity['average'][$bsRow['stat_uri']] = $bsRow['post_count']; } else { - if ($bsRow['stat_hour'] == $forHour) { - $boardActivity['active'][$bsRow['stat_uri']] = array_merge( $boardActivity['active'][$bsRow['stat_uri']], unserialize( $bsRow['author_ip_array'] ) ); - } - if ($bsRow['stat_hour'] <= $forHour && $bsRow['stat_hour'] >= $yesterHour) { $boardActivity['today'][$bsRow['stat_uri']] += $bsRow['post_count']; } + $boardActivity['active'][$bsRow['stat_uri']] = array_merge( $boardActivity['active'][$bsRow['stat_uri']], unserialize( $bsRow['author_ip_array'] ) ); $boardActivity['average'][$bsRow['stat_uri']] += $bsRow['post_count']; } }