1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-02-17 11:28:41 +01:00

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>
This commit is contained in:
8n-tech 2015-04-19 23:00:39 +10:00
parent 5f5dbbd163
commit 558152790d
3 changed files with 13 additions and 21 deletions

View File

@ -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'] );

View File

@ -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;

View File

@ -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'];
}
}