mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-07 09:21:12 +08:00
* 去除无用的auth_url * 修改readme * 修复计划任务生成sitemap.xml失败问题 * 增加课程推荐 * 增加后台刷新首页缓存小工具 * 调整公众号模板消息 * 增加刷新首页推荐课程缓存逻辑 * 更新课程综合评分算法 * 修复在线用户并发重复记录问题 * 增加限制共享帐号功能 * 修复数据迁移中无符号整型问题 * 更新版本为v1.2.3
45 lines
893 B
PHP
45 lines
893 B
PHP
<?php
|
|
|
|
namespace App\Console\Tasks;
|
|
|
|
use App\Repos\Course as CourseRepo;
|
|
use App\Services\CourseStat as CourseStatService;
|
|
use App\Services\Sync\CourseScore as CourseScoreSync;
|
|
|
|
class SyncCourseScoreTask extends Task
|
|
{
|
|
|
|
public function mainAction()
|
|
{
|
|
$redis = $this->getRedis();
|
|
|
|
$key = $this->getSyncKey();
|
|
|
|
$courseIds = $redis->sRandMember($key, 1000);
|
|
|
|
if (!$courseIds) return;
|
|
|
|
$courseRepo = new CourseRepo();
|
|
|
|
$courses = $courseRepo->findByIds($courseIds);
|
|
|
|
if ($courses->count() == 0) return;
|
|
|
|
$statService = new CourseStatService();
|
|
|
|
foreach ($courses as $course) {
|
|
$statService->updateScore($course->id);
|
|
}
|
|
|
|
$redis->sRem($key, ...$courseIds);
|
|
}
|
|
|
|
protected function getSyncKey()
|
|
{
|
|
$sync = new CourseScoreSync();
|
|
|
|
return $sync->getSyncKey();
|
|
}
|
|
|
|
}
|