企培版学习时长排行榜业务分析与时长为0错误

企培版学习时长排行榜业务分析

数据库查询条件

user_daily_learn_record.learnTime

src/CorporateTrainingBundle/Biz/DataStatistics/Dao/Impl/UserDailyLearnRecordJoinUserDaoImpl.php

public function statisticsPersonLearnTimeRankingList(array $conditions, $start = 0, $limit = 5)
{
    $builder = $this->db()->createQueryBuilder()
        ->select('udlr.userId as userId, MAX(udlr.postId) as postId, SUM(udlr.learnTime)/COUNT(DISTINCT(uo.orgId)) as totalLearnTime')
        ->from('user_daily_learn_record', 'udlr')
        ->innerJoin('udlr', 'user', 'u', 'u.id=udlr.userId')
        ->innerJoin('udlr', 'user_org', 'uo', 'udlr.userId=uo.userId')
        ->where('u.locked = 0')
        ->andWhere('u.type != "system"')
        ->groupBy('userId')
        ->orderBy('totalLearnTime', 'DESC')
        ->setFirstResult($start)
        ->setMaxResults($limit);

    $builder = $this->addWhereToQueryBuilder($builder, $conditions);

    return $builder->execute()->fetchAll() ?: [];
}
course_task_trigger:
    path:  /course/{courseId}/task/{id}/trigger
    defaults: { _controller: AppBundle:Task:trigger }

启用方案

错误原因

因为视频类型的课时不提供更新的问题,怎么实现更新需要前端支持,替换后该方案无效

src/CorporateTrainingBundle/Biz/UserDailyLearnRecord/Event/UserDailyLearnRecordEventSubscriber.php

public function onWaveLearnTime(Event $event)
{
    $taskResultId = $event->getSubject();
    $learnTime = $event->getArgument('learnTime');

    $taskResult = $this->getTaskResultService()->getTaskResultById($taskResultId);

    $user = $this->getUserService()->getUser($taskResult['userId']);

    $courseId = $taskResult['courseId'];
    $course = $this->getCourseService()->getCourse($courseId);

    if (!$this->validateData($user, $course, $taskResult)) {
        return;
    }

    $data = $this->buildData($user, $course);
    $data['learnTime'] = $learnTime;

    $this->processDailyRecord('wave.learn.time', $data);
}
    
    protected function validateData($user, $course, $taskResult = [])
{
    if (empty($user) || empty($course) || !empty($user['locked'])) {
        return false;
    }

    if (in_array($user['id'], $course['teacherIds'])) {
        return false;
    }

    if (!empty($taskResult)) {
        $task = $this->getTaskService()->getTask($taskResult['courseTaskId']);
        if (in_array($task['type'], ['video', 'audio'])) {
            return false;
        }

        if ('live' === $task['type']) {
            $activity = $this->getActivityService()->getActivity($taskResult['taskId']);
            $liveActivity = $this->getLiveActivityService()->getLiveActivity($activity['mediaId']);
            if ('videoGenerated' === $liveActivity['replayStatus']) {
                return false;
            }
        }
    }

    return true;
}

你可能感兴趣的:(企培版学习时长排行榜业务分析与时长为0错误)