mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-16 23:40:01 +08:00
1.添加closeLiveTask
2.优化kg-back返回 3.优化统计分析代码位置
This commit is contained in:
parent
2ab6ae71cd
commit
4e1e8340b9
@ -18,6 +18,13 @@ abstract class Migration
|
||||
|
||||
abstract public function run();
|
||||
|
||||
protected function saveSettings(array $settings)
|
||||
{
|
||||
foreach ($settings as $setting) {
|
||||
$this->saveSetting($setting);
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveSetting(array $setting)
|
||||
{
|
||||
$settingRepo = new SettingRepo();
|
||||
@ -32,4 +39,4 @@ abstract class Migration
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
72
app/Console/Tasks/CloseLiveTask.php
Normal file
72
app/Console/Tasks/CloseLiveTask.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2024 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Console\Tasks;
|
||||
|
||||
use App\Caches\CourseChapterList as CourseChapterListCache;
|
||||
use App\Models\Chapter as ChapterModel;
|
||||
use App\Models\ChapterLive as ChapterLiveModel;
|
||||
use App\Repos\Chapter as ChapterRepo;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
|
||||
class CloseLiveTask extends Task
|
||||
{
|
||||
|
||||
public function mainAction()
|
||||
{
|
||||
$chapterLives = $this->findChapterLives();
|
||||
|
||||
echo sprintf('pending lives: %s', $chapterLives->count()) . PHP_EOL;
|
||||
|
||||
if ($chapterLives->count() == 0) return;
|
||||
|
||||
echo '------ start close live task ------' . PHP_EOL;
|
||||
|
||||
foreach ($chapterLives as $chapterLive) {
|
||||
|
||||
$chapterLive->status = ChapterLiveModel::STATUS_INACTIVE;
|
||||
|
||||
$chapterLive->update();
|
||||
|
||||
$chapterRepo = new ChapterRepo();
|
||||
|
||||
$chapter = $chapterRepo->findById($chapterLive->chapter_id);
|
||||
|
||||
$attrs = $chapter->attrs;
|
||||
$attrs['stream']['status'] = ChapterModel::SS_INACTIVE;
|
||||
$chapter->attrs = $attrs;
|
||||
|
||||
$chapter->update();
|
||||
|
||||
$cache = new CourseChapterListCache();
|
||||
|
||||
$cache->rebuild($chapterLive->course_id);
|
||||
}
|
||||
|
||||
echo '------ end close live task ------' . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找待关闭直播
|
||||
*
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset|ChapterLiveModel[]
|
||||
*/
|
||||
protected function findChapterLives(int $limit = 100)
|
||||
{
|
||||
$status = ChapterLiveModel::STATUS_ACTIVE;
|
||||
$endTime = time() - 3600;
|
||||
|
||||
return ChapterLiveModel::query()
|
||||
->where('status = :status:', ['status' => $status])
|
||||
->andWhere('end_time < :end_time:', ['end_time' => $endTime])
|
||||
->limit($limit)
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
<div class="kg-nav-left">
|
||||
<span class="layui-breadcrumb">
|
||||
{% if parent.id > 0 %}
|
||||
<a class="kg-back" href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
|
||||
<a href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
|
||||
<a><cite>{{ parent.name }}</cite></a>
|
||||
{% endif %}
|
||||
<a><cite>分类管理</cite></a>
|
||||
@ -87,4 +87,4 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@ -43,7 +43,7 @@
|
||||
<div class="kg-nav">
|
||||
<div class="kg-nav-left">
|
||||
<span class="layui-breadcrumb">
|
||||
<a class="kg-back" href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
|
||||
<a href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
|
||||
<a><cite>{{ course.title }}</cite></a>
|
||||
<a><cite>{{ chapter.title }}</cite></a>
|
||||
<a><cite>课时管理</cite></a>
|
||||
@ -126,4 +126,4 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@ -9,7 +9,7 @@
|
||||
<div class="kg-nav">
|
||||
<div class="kg-nav-left">
|
||||
<span class="layui-breadcrumb">
|
||||
<a class="kg-back" href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
|
||||
<a href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
|
||||
<a><cite>{{ course.title }}</cite></a>
|
||||
<a><cite>章节管理</cite></a>
|
||||
</span>
|
||||
@ -79,4 +79,4 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@ -25,9 +25,7 @@
|
||||
<div class="kg-nav-left">
|
||||
<span class="layui-breadcrumb">
|
||||
{% if parent.id > 0 %}
|
||||
<a class="kg-back" href="{{ back_url }}">
|
||||
<i class="layui-icon layui-icon-return"></i> 返回
|
||||
</a>
|
||||
<a href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
|
||||
<a><cite>{{ parent.name }}</cite></a>
|
||||
{% endif %}
|
||||
<a><cite>导航管理</cite></a>
|
||||
|
@ -1,6 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN-Hans">
|
||||
<head>
|
||||
{% if site_info.analytics_enabled == 1 %}
|
||||
{{ site_info.analytics_script }}
|
||||
{% endif %}
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
@ -38,12 +41,5 @@
|
||||
|
||||
{% block include_js %}{% endblock %}
|
||||
{% block inline_js %}{% endblock %}
|
||||
|
||||
{% if site_info.analytics_enabled == 1 %}
|
||||
<div class="layui-hide">
|
||||
{{ site_info.analytics_script }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Caches\CourseChapterList as CatalogCache;
|
||||
use App\Caches\CourseChapterList as CourseChapterListCache;
|
||||
use App\Models\Chapter as ChapterModel;
|
||||
use App\Models\ChapterLive as ChapterLiveModel;
|
||||
use App\Repos\Chapter as ChapterRepo;
|
||||
@ -175,7 +175,7 @@ class LiveNotify extends Service
|
||||
|
||||
protected function rebuildCatalogCache(ChapterModel $chapter)
|
||||
{
|
||||
$cache = new CatalogCache();
|
||||
$cache = new CourseChapterListCache();
|
||||
|
||||
$cache->rebuild($chapter->course_id);
|
||||
}
|
||||
@ -216,4 +216,4 @@ class LiveNotify extends Service
|
||||
return $sign == $mySign;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,9 @@ $scheduler->php($script, $bin, ['--task' => 'sync_article_score', '--action' =>
|
||||
$scheduler->php($script, $bin, ['--task' => 'sync_question_score', '--action' => 'main'])
|
||||
->hourly(29);
|
||||
|
||||
$scheduler->php($script, $bin, ['--task' => 'close_live', '--action' => 'main'])
|
||||
->hourly(31);
|
||||
|
||||
$scheduler->php($script, $bin, ['--task' => 'clean_log', '--action' => 'main'])
|
||||
->daily(3, 3);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user