示例#1
0
<?php

require_once __DIR__ . '/../src/core.php';
CronRunner::run(__FILE__, function ($logger) {
    $userCount = Model_User::getCount();
    $userCountActive = Model_User::getCountActive();
    $mediaCount = [];
    $distArr = [];
    foreach (Media::getConstList() as $media) {
        $distArr[$media] = [];
        $mediaCount[$media] = Model_Media::getCount($media);
    }
    foreach (Media::getConstList() as $media) {
        $localDist = Model_MixedUserMedia::getRatingDistribution($media);
        foreach ($localDist->getGroupsKeys() as $key) {
            if (!isset($distArr[$media][$key])) {
                $distArr[$media][$key] = 0;
            }
            $distArr[$media][$key] += $localDist->getGroupSize($key);
        }
    }
    $globalsCache = ['user-count' => $userCount, 'user-count-active' => $userCountActive, 'media-count' => $mediaCount, 'rating-dist' => $distArr];
    TextHelper::putJson(Config::$globalsCachePath, $globalsCache);
});
示例#2
0
<?php

require_once __DIR__ . '/../src/core.php';
CronRunner::run(__FILE__, function ($logger) {
    $limit = 2 * 24 * 60 / 5;
    $queueSizes = TextHelper::loadJson(Config::$userQueueSizesPath, true);
    $userQueue = new Queue(Config::$userQueuePath);
    $mediaQueue = new Queue(Config::$mediaQueuePath);
    $key = date('c');
    $queueSizes[$key] = [$userQueue->size(), $mediaQueue->size()];
    ksort($queueSizes, SORT_NATURAL | SORT_FLAG_CASE);
    while (count($queueSizes) > $limit) {
        array_shift($queueSizes);
    }
    TextHelper::putJson(Config::$userQueueSizesPath, $queueSizes);
});