src/Biz/UserLearnStatistics/Job/SyncDaily.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace Biz\UserLearnStatistics\Job;

use Codeages\Biz\Framework\Scheduler\AbstractJob;

class SyncDaily extends AbstractJob
{
    public function execute()
    {
        //每天生成学习数据
        $learnSetting = $this->getLearnStatisticsService()->getStatisticsSetting();
        $cursor = $this->getSyncTime($learnSetting);
        $nextCursor = $cursor + 24 * 60 * 60;

        if (time() < $nextCursor) {
            return;
        }

        while (date('Y-m-d', $nextCursor) != date('Y-m-d', strtotime('+1 day'))) {
            $job = array(
                'name' => 'SyncDailyChildrenJob',
                'source' => 'MAIN',
                'expression' => intval(time()),
                'class' => 'Biz\UserLearnStatistics\Job\SyncDailyChildrenJob',
                'args' => array('cursor' => $cursor, 'nextCursor' => $nextCursor, 'learnStatisticsTime' => $learnSetting['currentTime']),
                'misfire_policy' => 'executing',
            );
            $this->getSchedulerService()->register($job);

            $cursor = $nextCursor;
            $nextCursor += 24 * 60 * 60;
        }

        $jobArgs['cursor'] = $cursor;
        $this->getJobDao()->update($this->id, array('args' => $jobArgs));
    }

    private function getSyncTime($learnSetting)
    {
        $jobArgs = $this->args;
        if (empty($jobArgs)) {
            $jobArgs = array();
        }

        return empty($jobArgs['cursor']) ? $learnSetting['currentTime'] : $jobArgs['cursor'];
    }

    protected function getSchedulerService()
    {
        return $this->biz->service('Scheduler:SchedulerService');
    }

    /**
     * @return \Biz\UserLearnStatistics\Service\Impl\LearnStatisticsServiceImpl
     */
    protected function getLearnStatisticsService()
    {
        return $this->biz->service('UserLearnStatistics:LearnStatisticsService');
    }

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。