diff --git a/app/Caches/ChapterCounter.php b/app/Caches/ChapterCounter.php deleted file mode 100644 index d6370b18..00000000 --- a/app/Caches/ChapterCounter.php +++ /dev/null @@ -1,37 +0,0 @@ -lifetime; - } - - public function getKey($id = null) - { - return "chapter_counter:{$id}"; - } - - public function getContent($id = null) - { - $chapterRepo = new ChapterRepo(); - - $chapter = $chapterRepo->findById($id); - - if (!$chapter) return null; - - return [ - 'user_count' => $chapter->user_count, - 'consult_count' => $chapter->consult_count, - 'like_count' => $chapter->like_count, - ]; - } - -} diff --git a/app/Caches/ConsultCounter.php b/app/Caches/ConsultCounter.php deleted file mode 100644 index 0e16c623..00000000 --- a/app/Caches/ConsultCounter.php +++ /dev/null @@ -1,35 +0,0 @@ -lifetime; - } - - public function getKey($id = null) - { - return "consult_counter:{$id}"; - } - - public function getContent($id = null) - { - $consultRepo = new ConsultRepo(); - - $consult = $consultRepo->findById($id); - - if (!$consult) return null; - - return [ - 'like_count' => $consult->like_count, - ]; - } - -} diff --git a/app/Caches/CourseCounter.php b/app/Caches/CourseCounter.php deleted file mode 100644 index 793cfc18..00000000 --- a/app/Caches/CourseCounter.php +++ /dev/null @@ -1,40 +0,0 @@ -lifetime; - } - - public function getKey($id = null) - { - return "course_counter:{$id}"; - } - - public function getContent($id = null) - { - $courseRepo = new CourseRepo(); - - $course = $courseRepo->findById($id); - - if (!$course) return null; - - return [ - 'user_count' => $course->user_count, - 'lesson_count' => $course->lesson_count, - 'comment_count' => $course->comment_count, - 'consult_count' => $course->consult_count, - 'review_count' => $course->review_count, - 'favorite_count' => $course->favorite_count, - ]; - } - -} diff --git a/app/Caches/ReviewCounter.php b/app/Caches/ReviewCounter.php deleted file mode 100644 index 6d23b686..00000000 --- a/app/Caches/ReviewCounter.php +++ /dev/null @@ -1,35 +0,0 @@ -lifetime; - } - - public function getKey($id = null) - { - return "review_counter:{$id}"; - } - - public function getContent($id = null) - { - $reviewRepo = new ReviewRepo(); - - $review = $reviewRepo->findById($id); - - if (!$review) return null; - - return [ - 'like_count' => $review->like_count, - ]; - } - -} diff --git a/app/Console/Tasks/SyncChapterCounterTask.php b/app/Console/Tasks/SyncChapterCounterTask.php deleted file mode 100644 index 0e1b5ab4..00000000 --- a/app/Console/Tasks/SyncChapterCounterTask.php +++ /dev/null @@ -1,98 +0,0 @@ -cache = $this->getDI()->get('cache'); - - $this->redis = $this->cache->getRedis(); - - $this->rebuild(); - } - - protected function rebuild() - { - $key = $this->getCacheKey(); - - $chapterIds = $this->redis->sRandMember($key, 500); - - if (!$chapterIds) return; - - $chapterRepo = new ChapterRepo(); - - $chapters = $chapterRepo->findByIds($chapterIds); - - if ($chapters->count() == 0) { - return; - } - - $counterCache = new ChapterCounterCache(); - - $chapterCache = new ChapterCache(); - - $allowRecount = $this->allowRecount(); - - foreach ($chapters as $chapter) { - - if ($allowRecount) { - - $chapter->user_count = $chapterRepo->countUsers($chapter->id); - $chapter->comment_count = $chapterRepo->countComments($chapter->id); - $chapter->like_count = $chapterRepo->countLikes($chapter->id); - $chapter->update(); - - $counterCache->rebuild($chapter->id); - $chapterCache->rebuild($chapter->id); - - } else { - - $counter = $counterCache->get($chapter->id); - - if ($counter) { - - $chapter->user_count = $counter['user_count']; - $chapter->comment_count = $counter['comment_count']; - $chapter->like_count = $counter['like_count']; - $chapter->update(); - - $chapterCache->rebuild($chapter->id); - } - } - } - - $this->redis->sRem($key, ...$chapterIds); - } - - protected function getCacheKey() - { - $syncer = new ChapterCounterSyncer(); - - return $syncer->getSyncKey(); - } - - protected function allowRecount() - { - return date('H') % 3 == 0; - } - -} diff --git a/app/Console/Tasks/SyncConsultCounterTask.php b/app/Console/Tasks/SyncConsultCounterTask.php deleted file mode 100644 index 0eff2802..00000000 --- a/app/Console/Tasks/SyncConsultCounterTask.php +++ /dev/null @@ -1,87 +0,0 @@ -cache = $this->getDI()->get('cache'); - - $this->redis = $this->cache->getRedis(); - - $this->rebuild(); - } - - protected function rebuild() - { - $key = $this->getCacheKey(); - - $consultIds = $this->redis->sRandMember($key, 500); - - if (!$consultIds) return; - - $consultRepo = new ConsultRepo(); - - $consults = $consultRepo->findByIds($consultIds); - - if ($consults->count() == 0) { - return; - } - - $counterCache = new ConsultCounterCache(); - - $allowRecount = $this->allowRecount(); - - foreach ($consults as $consult) { - - if ($allowRecount) { - - $consult->like_count = $consultRepo->countLikes($consult->id); - $consult->update(); - - $counterCache->rebuild($consult->id); - - } else { - - $counter = $counterCache->get($consult->id); - - if ($counter) { - $consult->like_count = $counter['like_count']; - $consult->update(); - } - } - } - - $this->redis->sRem($key, ...$consultIds); - } - - protected function getCacheKey() - { - $syncer = new ConsultCounterSyncer(); - - return $syncer->getSyncKey(); - } - - protected function allowRecount() - { - return date('H') % 4 == 0; - } - -} diff --git a/app/Console/Tasks/SyncCourseCounterTask.php b/app/Console/Tasks/SyncCourseCounterTask.php deleted file mode 100644 index 9aafe98f..00000000 --- a/app/Console/Tasks/SyncCourseCounterTask.php +++ /dev/null @@ -1,102 +0,0 @@ -cache = $this->getDI()->get('cache'); - - $this->redis = $this->cache->getRedis(); - - $this->rebuild(); - } - - protected function rebuild() - { - $key = $this->getCacheKey(); - - $courseIds = $this->redis->sRandMember($key, 100); - - if (!$courseIds) return; - - $courseRepo = new CourseRepo(); - - $courses = $courseRepo->findByIds($courseIds); - - if ($courses->count() == 0) { - return; - } - - $counterCache = new CourseCounterCache(); - - $courseCache = new CourseCache(); - - $allowRecount = $this->allowRecount(); - - foreach ($courses as $course) { - - if ($allowRecount) { - - $course->user_count = $courseRepo->countUsers($course->id); - $course->comment_count = $courseRepo->countComments($course->id); - $course->consult_count = $courseRepo->countConsults($course->id); - $course->review_count = $courseRepo->countReviews($course->id); - $course->favorite_count = $courseRepo->countFavorites($course->id); - $course->update(); - - $counterCache->rebuild($course->id); - $courseCache->rebuild($course->id); - - } else { - - $counter = $counterCache->get($course->id); - - if ($counter) { - - $course->user_count = $counter['user_count']; - $course->comment_count = $counter['comment_count']; - $course->consult_count = $counter['consult_count']; - $course->review_count = $counter['review_count']; - $course->favorite_count = $counter['favorite_count']; - $course->update(); - - $courseCache->rebuild($course->id); - } - } - } - - $this->redis->sRem($key, ...$courseIds); - } - - protected function getCacheKey() - { - $syncer = new CourseCounterSyncer(); - - return $syncer->getSyncKey(); - } - - protected function allowRecount() - { - return date('H') % 3 == 0; - } - -} diff --git a/app/Console/Tasks/SyncReviewCounterTask.php b/app/Console/Tasks/SyncReviewCounterTask.php deleted file mode 100644 index 63990997..00000000 --- a/app/Console/Tasks/SyncReviewCounterTask.php +++ /dev/null @@ -1,87 +0,0 @@ -cache = $this->getDI()->get('cache'); - - $this->redis = $this->cache->getRedis(); - - $this->rebuild(); - } - - protected function rebuild() - { - $key = $this->getCacheKey(); - - $reviewIds = $this->redis->sRandMember($key, 500); - - if (!$reviewIds) return; - - $reviewRepo = new ReviewRepo(); - - $reviews = $reviewRepo->findByIds($reviewIds); - - if ($reviews->count() == 0) { - return; - } - - $counterCache = new ReviewCounterCache(); - - $allowRecount = $this->allowRecount(); - - foreach ($reviews as $review) { - - if ($allowRecount) { - - $review->like_count = $reviewRepo->countLikes($review->id); - $review->update(); - - $counterCache->rebuild($review->id); - - } else { - - $counter = $counterCache->get($review->id); - - if ($counter) { - $review->like_count = $counter['like_count']; - $review->update(); - } - } - } - - $this->redis->sRem($key, ...$reviewIds); - } - - protected function getCacheKey() - { - $syncer = new ReviewCounterSyncer(); - - return $syncer->getSyncKey(); - } - - protected function allowRecount() - { - return date('H') % 4 == 0; - } - -} diff --git a/app/Http/Admin/Views/student/learning.volt b/app/Http/Admin/Views/student/learning.volt index 05bd4bfe..33214f29 100644 --- a/app/Http/Admin/Views/student/learning.volt +++ b/app/Http/Admin/Views/student/learning.volt @@ -25,7 +25,7 @@

类型:{{ item.client_type }}

地址:{{ item.client_ip }}

- {{ item.duration|total_duration }} + {{ item.duration|duration }} {{ date('Y-m-d H:i:s',item.active_time) }} {% endfor %} diff --git a/app/Http/Admin/Views/student/list.volt b/app/Http/Admin/Views/student/list.volt index 82231584..3aae95cf 100644 --- a/app/Http/Admin/Views/student/list.volt +++ b/app/Http/Admin/Views/student/list.volt @@ -61,7 +61,7 @@

进度:{{ item.progress }}%

-

时长:{{ item.duration|total_duration }}

+

时长:{{ item.duration|duration }}

{{ source_type_info(item.source_type) }} diff --git a/app/Http/Web/Controllers/CourseController.php b/app/Http/Web/Controllers/CourseController.php index 60037d7c..dfce713d 100644 --- a/app/Http/Web/Controllers/CourseController.php +++ b/app/Http/Web/Controllers/CourseController.php @@ -71,10 +71,6 @@ class CourseController extends Controller $course = $service->handle($id); - $service = new CourseQueryService(); - - $course['category_paths'] = $service->handleCategoryPaths($course['category_id']); - $service = new RewardOptionList(); $rewards = $service->handle(); diff --git a/app/Http/Web/Controllers/MyController.php b/app/Http/Web/Controllers/MyController.php index 64de4886..c80104cd 100644 --- a/app/Http/Web/Controllers/MyController.php +++ b/app/Http/Web/Controllers/MyController.php @@ -51,6 +51,30 @@ class MyController extends Controller $this->view->setVar('account', $account); } + /** + * @Get("/courses", name="web.my.courses") + */ + public function coursesAction() + { + $service = new MyConsultListService(); + + $pager = $service->handle(); + + $this->view->setVar('pager', $pager); + } + + /** + * @Get("/favorites", name="web.my.favorites") + */ + public function favoritesAction() + { + $service = new MyConsultListService(); + + $pager = $service->handle(); + + $this->view->setVar('pager', $pager); + } + /** * @Get("/consults", name="web.my.consults") */ diff --git a/app/Http/Web/Views/chapter/live.volt b/app/Http/Web/Views/chapter/live.volt index c514481f..984101b8 100644 --- a/app/Http/Web/Views/chapter/live.volt +++ b/app/Http/Web/Views/chapter/live.volt @@ -74,7 +74,7 @@ {{ js_include('web/js/chapter.live.player.js') }} {{ js_include('web/js/chapter.live.im.js') }} - {{ js_include('web/js/chapter.like.js') }} + {{ js_include('web/js/chapter.action.js') }} {{ js_include('web/js/course.share.js') }} {% endblock %} \ No newline at end of file diff --git a/app/Http/Web/Views/chapter/read.volt b/app/Http/Web/Views/chapter/read.volt index 0e193ba8..1950232e 100644 --- a/app/Http/Web/Views/chapter/read.volt +++ b/app/Http/Web/Views/chapter/read.volt @@ -6,6 +6,7 @@ {% set course_url = url({'for':'web.course.show','id':chapter.course.id}) %} {% set learning_url = url({'for':'web.chapter.learning','id':chapter.id}) %} {% set like_url = url({'for':'web.chapter.like','id':chapter.id}) %} + {% set consult_url = url({'for':'web.consult.add'},{'chapter_id':chapter.id}) %} {% set qrcode_url = url({'for':'web.qrcode_img'},{'text':chapter_full_url}) %}