From 672008f60da34b9699963ebf381fcb2d4edd0e39 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 15 Jul 2019 13:04:27 +0900 Subject: [PATCH 01/20] =?UTF-8?q?change:=20UptimeRobot=E3=81=AF=E9=99=A4?= =?UTF-8?q?=E5=A4=96=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/AccessCountersController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Controller/AccessCountersController.php b/Controller/AccessCountersController.php index 70251f0..0490c6c 100644 --- a/Controller/AccessCountersController.php +++ b/Controller/AccessCountersController.php @@ -78,7 +78,7 @@ public function view() { $accessCounter = $this->AccessCounter->getAccessCounter(true); // カウントアップ処理 - if (! $this->Session->read($isAccessed)) { + if (! $this->Session->read($isAccessed) && ! $this->__isUptimeRobot()) { try { $this->AccessCounter->updateCountUp($accessCounter); $accessCounter['AccessCounter']['count']++; @@ -94,6 +94,16 @@ public function view() { $this->set('accessCounter', $accessCounter['AccessCounter']); } +/** + * UptimeRobotのアクセスか否か + * + * @return bool + */ + private function __isUptimeRobot() { + $userAgent = env('HTTP_USER_AGENT'); + return (bool)strpos($userAgent, 'UptimeRobot/2.0'); + } + /** * add * From a96f2d597497847a03f050dcb8f7beff823de9f7 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 15 Jul 2019 13:31:54 +0900 Subject: [PATCH 02/20] =?UTF-8?q?fix:=20env=E3=81=AE=E6=88=BB=E3=82=8A?= =?UTF-8?q?=E5=80=A4=E3=82=92=E6=96=87=E5=AD=97=E5=88=97=E3=81=A7=E3=82=AD?= =?UTF-8?q?=E3=83=A3=E3=82=B9=E3=83=88=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/AccessCountersController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/AccessCountersController.php b/Controller/AccessCountersController.php index 0490c6c..6fdbb37 100644 --- a/Controller/AccessCountersController.php +++ b/Controller/AccessCountersController.php @@ -101,7 +101,7 @@ public function view() { */ private function __isUptimeRobot() { $userAgent = env('HTTP_USER_AGENT'); - return (bool)strpos($userAgent, 'UptimeRobot/2.0'); + return (bool)strpos((string)$userAgent, 'UptimeRobot/2.0'); } /** From f038c1ca9f4cc975162ccc5323bf3e6605cf382b Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Fri, 24 Jan 2020 13:56:56 +0900 Subject: [PATCH 03/20] feat: re-fetch access counter lazily --- Controller/AccessCountersController.php | 58 ++++++++++++++++--------- Model/AccessCounter.php | 5 +++ View/AccessCounters/view.ctp | 18 +++----- webroot/js/access_counters.js | 27 ++++++++++++ 4 files changed, 76 insertions(+), 32 deletions(-) diff --git a/Controller/AccessCountersController.php b/Controller/AccessCountersController.php index 70251f0..d38b33d 100644 --- a/Controller/AccessCountersController.php +++ b/Controller/AccessCountersController.php @@ -4,6 +4,7 @@ * * @author Noriko Arai * @author Shohei Nakajima + * @author Kazunori Sakamoto * @link http://www.netcommons.org NetCommons Project * @license http://www.netcommons.org/license.txt NetCommons License * @copyright Copyright 2014, NetCommons Project @@ -15,6 +16,7 @@ * AccessCounters Controller * * @author Shohei Nakajima + * @author Kazunori Sakamoto * @package NetCommons\AccessCounters\Controller */ class AccessCountersController extends AccessCountersAppController { @@ -65,33 +67,47 @@ class AccessCountersController extends AccessCountersAppController { */ public function view() { if (! Current::read('Block.id')) { - $this->autoRender = false; - return; + if (! $this->request->is('ajax')) { + $this->autoRender = false; + return; + } + + // AccessCounterデータ取得 + $accessCounter = $this->AccessCounter->getAccessCounter(false); + } else { + // AccessCounterデータ取得 + $accessCounter = $this->AccessCounter->getAccessCounter(true); + + // カウントアップ処理 + $isAccessed = 'block_key_' . Current::read('Block.key'); + if (! $this->Session->read($isAccessed)) { + try { + $this->AccessCounter->updateCountUp($accessCounter); + $accessCounter['AccessCounter']['count']++; + // アクセス情報を記録 + $this->Session->write($isAccessed, CakeSession::read('Config.userAgent')); + + } catch (Exception $ex) { + CakeLog::error($ex); + throw $ex; + } + } } - $isAccessed = 'block_key_' . Current::read('Block.key'); - //AccessCounterFrameSettingデータ取得 + if ($this->request->is('ajax')) { + $this->response->header('Pragma', 'no-cache'); + $this->set('_serialize', ['counterText']); + } + + // AccessCounterFrameSettingデータ取得 $counterFrameSetting = $this->AccessCounterFrameSetting->getAccessCounterFrameSetting(true); $this->set('accessCounterFrameSetting', $counterFrameSetting['AccessCounterFrameSetting']); - //AccessCounterデータ取得 - $accessCounter = $this->AccessCounter->getAccessCounter(true); - - // カウントアップ処理 - if (! $this->Session->read($isAccessed)) { - try { - $this->AccessCounter->updateCountUp($accessCounter); - $accessCounter['AccessCounter']['count']++; - // アクセス情報を記録 - $this->Session->write($isAccessed, CakeSession::read('Config.userAgent')); - - } catch (Exception $ex) { - CakeLog::error($ex); - throw $ex; - } - } + $type = $counterFrameSetting['AccessCounterFrameSetting']['display_type']; + $this->set('displayType', AccessCounterFrameSetting::$displayTypes[$type]); - $this->set('accessCounter', $accessCounter['AccessCounter']); + $format = '%0' . (int)$counterFrameSetting['AccessCounterFrameSetting']['display_digit'] . 'd'; + $this->set('counterText', sprintf($format, $accessCounter['AccessCounter']['count'])); } /** diff --git a/Model/AccessCounter.php b/Model/AccessCounter.php index 4554bb0..066552a 100644 --- a/Model/AccessCounter.php +++ b/Model/AccessCounter.php @@ -4,6 +4,7 @@ * * @author Noriko Arai * @author Shohei Nakajima + * @author Kazunori Sakamoto * @link http://www.netcommons.org NetCommons Project * @license http://www.netcommons.org/license.txt NetCommons License * @copyright Copyright 2014, NetCommons Project @@ -15,6 +16,7 @@ * AccessCounter Model * * @author Shohei Nakajima + * @author Kazunori Sakamoto * @package NetCommons\AccessCounters\Model */ class AccessCounter extends AccessCountersAppModel { @@ -257,6 +259,8 @@ public function deleteAccessCounter($data) { * @throws InternalErrorException */ public function updateCountUp($data) { + $this->invalidateCDN = false; + $this->loadModels([ 'AccessCounter' => 'AccessCounters.AccessCounter', ]); @@ -282,6 +286,7 @@ public function updateCountUp($data) { $this->rollback($ex); } + $this->invalidateCDN = true; return true; } diff --git a/View/AccessCounters/view.ctp b/View/AccessCounters/view.ctp index d5278f2..c7078b9 100644 --- a/View/AccessCounters/view.ctp +++ b/View/AccessCounters/view.ctp @@ -4,21 +4,17 @@ * * @author Noriko Arai * @author Shohei Nakajima + * @author Kazunori Sakamoto * @link http://www.netcommons.org NetCommons Project * @license http://www.netcommons.org/license.txt NetCommons License * @copyright Copyright 2014, NetCommons Project */ + +echo $this->NetCommonsHtml->script('/access_counters/js/access_counters.js'); ?> -
- - - - - - +
+ + {{counterChar}} +
diff --git a/webroot/js/access_counters.js b/webroot/js/access_counters.js index b76d715..a85c3dc 100644 --- a/webroot/js/access_counters.js +++ b/webroot/js/access_counters.js @@ -1,9 +1,36 @@ /** * @fileoverview AccessCounters Javascript * @author nakajimashouhei@gmail.com (Shohei Nakajima) + * @author exkazuu@gmail.com (Kazunori Sakamoto) */ +/** + * AccessCounters Controller Javascript + * + * @param {string} Controller name + * @param {function($scope, LikesLoad, LikesSave)} Controller + */ +NetCommonsApp.controller('AccessCounters', ['$scope', '$http', 'NC3_URL', function($scope, $http, NC3_URL) { + + /** + * initialize + * + * @return {void} + */ + $scope.initialize = function(frameId, counterText) { + $scope.counterText = counterText; + $http.get(NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId) + .then( + function(response) { + $scope.counterText = response.data.counterText; + }, + function() { + }); + }; +}]); + + /** * AccessCounterFrameSettings Javascript * From bcc7de07503f80290fefcfd78c64b93621f835f2 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Fri, 24 Jan 2020 14:05:04 +0900 Subject: [PATCH 04/20] feat: re-fetch access counter lazily --- Controller/AccessCountersController.php | 58 ++++++++++++++++--------- Model/AccessCounter.php | 5 +++ View/AccessCounters/view.ctp | 18 +++----- webroot/js/access_counters.js | 27 ++++++++++++ 4 files changed, 76 insertions(+), 32 deletions(-) diff --git a/Controller/AccessCountersController.php b/Controller/AccessCountersController.php index 6fdbb37..bd699a5 100644 --- a/Controller/AccessCountersController.php +++ b/Controller/AccessCountersController.php @@ -4,6 +4,7 @@ * * @author Noriko Arai * @author Shohei Nakajima + * @author Kazunori Sakamoto * @link http://www.netcommons.org NetCommons Project * @license http://www.netcommons.org/license.txt NetCommons License * @copyright Copyright 2014, NetCommons Project @@ -15,6 +16,7 @@ * AccessCounters Controller * * @author Shohei Nakajima + * @author Kazunori Sakamoto * @package NetCommons\AccessCounters\Controller */ class AccessCountersController extends AccessCountersAppController { @@ -65,33 +67,47 @@ class AccessCountersController extends AccessCountersAppController { */ public function view() { if (! Current::read('Block.id')) { - $this->autoRender = false; - return; + if (! $this->request->is('ajax')) { + $this->autoRender = false; + return; + } + + // AccessCounterデータ取得 + $accessCounter = $this->AccessCounter->getAccessCounter(false); + } else { + // AccessCounterデータ取得 + $accessCounter = $this->AccessCounter->getAccessCounter(true); + + // カウントアップ処理 + $isAccessed = 'block_key_' . Current::read('Block.key'); + if (! $this->Session->read($isAccessed) && ! $this->__isUptimeRobot()) { + try { + $this->AccessCounter->updateCountUp($accessCounter); + $accessCounter['AccessCounter']['count']++; + // アクセス情報を記録 + $this->Session->write($isAccessed, CakeSession::read('Config.userAgent')); + + } catch (Exception $ex) { + CakeLog::error($ex); + throw $ex; + } + } } - $isAccessed = 'block_key_' . Current::read('Block.key'); - //AccessCounterFrameSettingデータ取得 + if ($this->request->is('ajax')) { + $this->response->header('Pragma', 'no-cache'); + $this->set('_serialize', ['counterText']); + } + + // AccessCounterFrameSettingデータ取得 $counterFrameSetting = $this->AccessCounterFrameSetting->getAccessCounterFrameSetting(true); $this->set('accessCounterFrameSetting', $counterFrameSetting['AccessCounterFrameSetting']); - //AccessCounterデータ取得 - $accessCounter = $this->AccessCounter->getAccessCounter(true); - - // カウントアップ処理 - if (! $this->Session->read($isAccessed) && ! $this->__isUptimeRobot()) { - try { - $this->AccessCounter->updateCountUp($accessCounter); - $accessCounter['AccessCounter']['count']++; - // アクセス情報を記録 - $this->Session->write($isAccessed, CakeSession::read('Config.userAgent')); - - } catch (Exception $ex) { - CakeLog::error($ex); - throw $ex; - } - } + $type = $counterFrameSetting['AccessCounterFrameSetting']['display_type']; + $this->set('displayType', AccessCounterFrameSetting::$displayTypes[$type]); - $this->set('accessCounter', $accessCounter['AccessCounter']); + $format = '%0' . (int)$counterFrameSetting['AccessCounterFrameSetting']['display_digit'] . 'd'; + $this->set('counterText', sprintf($format, $accessCounter['AccessCounter']['count'])); } /** diff --git a/Model/AccessCounter.php b/Model/AccessCounter.php index 4554bb0..066552a 100644 --- a/Model/AccessCounter.php +++ b/Model/AccessCounter.php @@ -4,6 +4,7 @@ * * @author Noriko Arai * @author Shohei Nakajima + * @author Kazunori Sakamoto * @link http://www.netcommons.org NetCommons Project * @license http://www.netcommons.org/license.txt NetCommons License * @copyright Copyright 2014, NetCommons Project @@ -15,6 +16,7 @@ * AccessCounter Model * * @author Shohei Nakajima + * @author Kazunori Sakamoto * @package NetCommons\AccessCounters\Model */ class AccessCounter extends AccessCountersAppModel { @@ -257,6 +259,8 @@ public function deleteAccessCounter($data) { * @throws InternalErrorException */ public function updateCountUp($data) { + $this->invalidateCDN = false; + $this->loadModels([ 'AccessCounter' => 'AccessCounters.AccessCounter', ]); @@ -282,6 +286,7 @@ public function updateCountUp($data) { $this->rollback($ex); } + $this->invalidateCDN = true; return true; } diff --git a/View/AccessCounters/view.ctp b/View/AccessCounters/view.ctp index d5278f2..c7078b9 100644 --- a/View/AccessCounters/view.ctp +++ b/View/AccessCounters/view.ctp @@ -4,21 +4,17 @@ * * @author Noriko Arai * @author Shohei Nakajima + * @author Kazunori Sakamoto * @link http://www.netcommons.org NetCommons Project * @license http://www.netcommons.org/license.txt NetCommons License * @copyright Copyright 2014, NetCommons Project */ + +echo $this->NetCommonsHtml->script('/access_counters/js/access_counters.js'); ?> -
- - - - - - +
+ + {{counterChar}} +
diff --git a/webroot/js/access_counters.js b/webroot/js/access_counters.js index b76d715..a85c3dc 100644 --- a/webroot/js/access_counters.js +++ b/webroot/js/access_counters.js @@ -1,9 +1,36 @@ /** * @fileoverview AccessCounters Javascript * @author nakajimashouhei@gmail.com (Shohei Nakajima) + * @author exkazuu@gmail.com (Kazunori Sakamoto) */ +/** + * AccessCounters Controller Javascript + * + * @param {string} Controller name + * @param {function($scope, LikesLoad, LikesSave)} Controller + */ +NetCommonsApp.controller('AccessCounters', ['$scope', '$http', 'NC3_URL', function($scope, $http, NC3_URL) { + + /** + * initialize + * + * @return {void} + */ + $scope.initialize = function(frameId, counterText) { + $scope.counterText = counterText; + $http.get(NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId) + .then( + function(response) { + $scope.counterText = response.data.counterText; + }, + function() { + }); + }; +}]); + + /** * AccessCounterFrameSettings Javascript * From 53c79c8e2633c642530c5872ef2f8907c6de2283 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Fri, 24 Jan 2020 14:41:24 +0900 Subject: [PATCH 05/20] fix: pass as a string --- View/AccessCounters/view.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/View/AccessCounters/view.ctp b/View/AccessCounters/view.ctp index c7078b9..2eb30db 100644 --- a/View/AccessCounters/view.ctp +++ b/View/AccessCounters/view.ctp @@ -13,7 +13,7 @@ echo $this->NetCommonsHtml->script('/access_counters/js/access_counters.js'); ?> -
+
{{counterChar}} From d0f730dca87c8da0b8cdd7c2900aa9f5fa6ea6f4 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Thu, 6 Feb 2020 23:33:18 +0900 Subject: [PATCH 06/20] fix: use jQuery's ajax to disable browser cache (#65) --- webroot/js/access_counters.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/webroot/js/access_counters.js b/webroot/js/access_counters.js index a85c3dc..8028999 100644 --- a/webroot/js/access_counters.js +++ b/webroot/js/access_counters.js @@ -9,9 +9,9 @@ * AccessCounters Controller Javascript * * @param {string} Controller name - * @param {function($scope, LikesLoad, LikesSave)} Controller + * @param {function($scope, NC3_URL)} Controller */ -NetCommonsApp.controller('AccessCounters', ['$scope', '$http', 'NC3_URL', function($scope, $http, NC3_URL) { +NetCommonsApp.controller('AccessCounters', ['$scope', 'NC3_URL', function($scope, NC3_URL) { /** * initialize @@ -20,13 +20,15 @@ NetCommonsApp.controller('AccessCounters', ['$scope', '$http', 'NC3_URL', functi */ $scope.initialize = function(frameId, counterText) { $scope.counterText = counterText; - $http.get(NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId) - .then( - function(response) { - $scope.counterText = response.data.counterText; - }, - function() { - }); + $.ajax({ + url: NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId, + cache: false, + success: function (data) { + $scope.$apply(function() { + $scope.counterText = data.counterText; + }); + } + }); }; }]); From 57b442bb6198272a17d4744a00c960b32c004973 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Thu, 6 Feb 2020 23:35:24 +0900 Subject: [PATCH 07/20] fix: use jQuery's ajax to disable browser cache (NetCommons3#65) (#6) --- webroot/js/access_counters.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/webroot/js/access_counters.js b/webroot/js/access_counters.js index a85c3dc..8028999 100644 --- a/webroot/js/access_counters.js +++ b/webroot/js/access_counters.js @@ -9,9 +9,9 @@ * AccessCounters Controller Javascript * * @param {string} Controller name - * @param {function($scope, LikesLoad, LikesSave)} Controller + * @param {function($scope, NC3_URL)} Controller */ -NetCommonsApp.controller('AccessCounters', ['$scope', '$http', 'NC3_URL', function($scope, $http, NC3_URL) { +NetCommonsApp.controller('AccessCounters', ['$scope', 'NC3_URL', function($scope, NC3_URL) { /** * initialize @@ -20,13 +20,15 @@ NetCommonsApp.controller('AccessCounters', ['$scope', '$http', 'NC3_URL', functi */ $scope.initialize = function(frameId, counterText) { $scope.counterText = counterText; - $http.get(NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId) - .then( - function(response) { - $scope.counterText = response.data.counterText; - }, - function() { - }); + $.ajax({ + url: NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId, + cache: false, + success: function (data) { + $scope.$apply(function() { + $scope.counterText = data.counterText; + }); + } + }); }; }]); From 724980d4682c3c3e5c45e81f0038fe69d9583366 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Thu, 20 Feb 2020 14:09:41 +0900 Subject: [PATCH 08/20] fix: revert ajax request to use AngularJS (#66) --- webroot/js/access_counters.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/webroot/js/access_counters.js b/webroot/js/access_counters.js index 8028999..b9774b6 100644 --- a/webroot/js/access_counters.js +++ b/webroot/js/access_counters.js @@ -9,9 +9,9 @@ * AccessCounters Controller Javascript * * @param {string} Controller name - * @param {function($scope, NC3_URL)} Controller + * @param {function($scope, $http, NC3_URL)} Controller */ -NetCommonsApp.controller('AccessCounters', ['$scope', 'NC3_URL', function($scope, NC3_URL) { +NetCommonsApp.controller('AccessCounters', ['$scope', '$http', 'NC3_URL', function($scope, $http, NC3_URL) { /** * initialize @@ -20,15 +20,13 @@ NetCommonsApp.controller('AccessCounters', ['$scope', 'NC3_URL', function($scope */ $scope.initialize = function(frameId, counterText) { $scope.counterText = counterText; - $.ajax({ - url: NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId, - cache: false, - success: function (data) { - $scope.$apply(function() { - $scope.counterText = data.counterText; + $http.get(NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId) + .then( + function(response) { + $scope.counterText = response.data.counterText; + }, + function() { }); - } - }); }; }]); From d50a3eee17caf6135ffc88945827ded19e020d24 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Fri, 21 Feb 2020 10:19:52 +0900 Subject: [PATCH 09/20] fix: pass $http parameter --- webroot/js/access_counters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webroot/js/access_counters.js b/webroot/js/access_counters.js index 8ae7a6c..b9774b6 100644 --- a/webroot/js/access_counters.js +++ b/webroot/js/access_counters.js @@ -11,7 +11,7 @@ * @param {string} Controller name * @param {function($scope, $http, NC3_URL)} Controller */ -NetCommonsApp.controller('AccessCounters', ['$scope', 'NC3_URL', function($scope, NC3_URL) { +NetCommonsApp.controller('AccessCounters', ['$scope', '$http', 'NC3_URL', function($scope, $http, NC3_URL) { /** * initialize From 69fd0c8c294e0a3a8ac05c5e668067b93d3ae324 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Fri, 24 Jan 2020 14:41:24 +0900 Subject: [PATCH 10/20] fix: pass conunterText as a string --- View/AccessCounters/view.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/View/AccessCounters/view.ctp b/View/AccessCounters/view.ctp index c7078b9..2eb30db 100644 --- a/View/AccessCounters/view.ctp +++ b/View/AccessCounters/view.ctp @@ -13,7 +13,7 @@ echo $this->NetCommonsHtml->script('/access_counters/js/access_counters.js'); ?> -
+
{{counterChar}} From 47319f11a31e4202f891d051a88cbce149ccca43 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Thu, 6 Feb 2020 23:33:18 +0900 Subject: [PATCH 11/20] fix: use jQuery's ajax to disable browser cache (#65) --- webroot/js/access_counters.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/webroot/js/access_counters.js b/webroot/js/access_counters.js index a85c3dc..8028999 100644 --- a/webroot/js/access_counters.js +++ b/webroot/js/access_counters.js @@ -9,9 +9,9 @@ * AccessCounters Controller Javascript * * @param {string} Controller name - * @param {function($scope, LikesLoad, LikesSave)} Controller + * @param {function($scope, NC3_URL)} Controller */ -NetCommonsApp.controller('AccessCounters', ['$scope', '$http', 'NC3_URL', function($scope, $http, NC3_URL) { +NetCommonsApp.controller('AccessCounters', ['$scope', 'NC3_URL', function($scope, NC3_URL) { /** * initialize @@ -20,13 +20,15 @@ NetCommonsApp.controller('AccessCounters', ['$scope', '$http', 'NC3_URL', functi */ $scope.initialize = function(frameId, counterText) { $scope.counterText = counterText; - $http.get(NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId) - .then( - function(response) { - $scope.counterText = response.data.counterText; - }, - function() { - }); + $.ajax({ + url: NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId, + cache: false, + success: function (data) { + $scope.$apply(function() { + $scope.counterText = data.counterText; + }); + } + }); }; }]); From 3da5ae9fe4dafdb61313ca2a3dc132f2c9e0c7d9 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Thu, 20 Feb 2020 14:09:41 +0900 Subject: [PATCH 12/20] fix: revert ajax request to use AngularJS (#66) --- webroot/js/access_counters.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/webroot/js/access_counters.js b/webroot/js/access_counters.js index 8028999..b9774b6 100644 --- a/webroot/js/access_counters.js +++ b/webroot/js/access_counters.js @@ -9,9 +9,9 @@ * AccessCounters Controller Javascript * * @param {string} Controller name - * @param {function($scope, NC3_URL)} Controller + * @param {function($scope, $http, NC3_URL)} Controller */ -NetCommonsApp.controller('AccessCounters', ['$scope', 'NC3_URL', function($scope, NC3_URL) { +NetCommonsApp.controller('AccessCounters', ['$scope', '$http', 'NC3_URL', function($scope, $http, NC3_URL) { /** * initialize @@ -20,15 +20,13 @@ NetCommonsApp.controller('AccessCounters', ['$scope', 'NC3_URL', function($scope */ $scope.initialize = function(frameId, counterText) { $scope.counterText = counterText; - $.ajax({ - url: NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId, - cache: false, - success: function (data) { - $scope.$apply(function() { - $scope.counterText = data.counterText; + $http.get(NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId) + .then( + function(response) { + $scope.counterText = response.data.counterText; + }, + function() { }); - } - }); }; }]); From 686ed320a1c7a30c67807c1f9170fab14f0dddc3 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Tue, 25 Feb 2020 21:06:14 +0900 Subject: [PATCH 13/20] fix: remove redundant no-cache setting --- Controller/AccessCountersController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Controller/AccessCountersController.php b/Controller/AccessCountersController.php index d38b33d..3201bd8 100644 --- a/Controller/AccessCountersController.php +++ b/Controller/AccessCountersController.php @@ -95,7 +95,6 @@ public function view() { } if ($this->request->is('ajax')) { - $this->response->header('Pragma', 'no-cache'); $this->set('_serialize', ['counterText']); } From 3e4ccd8bc450e1e02bc652a6edce13cbe75b33ad Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Mon, 2 Mar 2020 10:34:49 +0900 Subject: [PATCH 14/20] refactor: code related to CDN cache invalidation --- Model/AccessCounter.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Model/AccessCounter.php b/Model/AccessCounter.php index 066552a..59d194a 100644 --- a/Model/AccessCounter.php +++ b/Model/AccessCounter.php @@ -259,8 +259,6 @@ public function deleteAccessCounter($data) { * @throws InternalErrorException */ public function updateCountUp($data) { - $this->invalidateCDN = false; - $this->loadModels([ 'AccessCounter' => 'AccessCounters.AccessCounter', ]); @@ -277,7 +275,9 @@ public function updateCountUp($data) { }; //トランザクションCommit + $this->invalidateCDN = false; $this->commit(); + $this->invalidateCDN = true; $this->setSlaveDataSource(); $this->getDataSource(); @@ -286,7 +286,6 @@ public function updateCountUp($data) { $this->rollback($ex); } - $this->invalidateCDN = true; return true; } From f4f12c094ef810ca74828a86ad885b490a571502 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sun, 8 Mar 2020 15:37:32 +0900 Subject: [PATCH 15/20] =?UTF-8?q?change:=20test:=20travis.yml=E3=81=8B?= =?UTF-8?q?=E3=82=89php5.4,5.5=E3=82=92=E5=89=8A=E9=99=A4=E3=80=82php7.3,7?= =?UTF-8?q?.4=E3=82=92=E8=BF=BD=E5=8A=A0=20https://github.com/NetCommons3/?= =?UTF-8?q?NetCommons3/issues/1560?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7e3782..dceeb48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,12 @@ language: php php: - - 5.4 - - 5.5 - 5.6 - 7.0 - 7.1 - 7.2 + - 7.3 + - 7.4 sudo: false dist: trusty From 7fd0e3d0d5df919a807d27ebbe3b7c615938730f Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 9 Mar 2020 08:13:03 +0900 Subject: [PATCH 16/20] =?UTF-8?q?change:=20gjslint=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E4=BF=AE=E6=AD=A3=20https://github.com/NetCommons3/Ne?= =?UTF-8?q?tCommons3/issues/1560?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webroot/js/access_counters.js | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/webroot/js/access_counters.js b/webroot/js/access_counters.js index b9774b6..61ac7ef 100644 --- a/webroot/js/access_counters.js +++ b/webroot/js/access_counters.js @@ -11,24 +11,25 @@ * @param {string} Controller name * @param {function($scope, $http, NC3_URL)} Controller */ -NetCommonsApp.controller('AccessCounters', ['$scope', '$http', 'NC3_URL', function($scope, $http, NC3_URL) { +NetCommonsApp.controller('AccessCounters', + ['$scope', '$http', 'NC3_URL', function($scope, $http, NC3_URL) { - /** - * initialize - * - * @return {void} - */ - $scope.initialize = function(frameId, counterText) { - $scope.counterText = counterText; - $http.get(NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId) - .then( - function(response) { - $scope.counterText = response.data.counterText; - }, - function() { - }); - }; -}]); + /** + * initialize + * + * @return {void} + */ + $scope.initialize = function(frameId, counterText) { + $scope.counterText = counterText; + $http.get(NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId) + .then( + function(response) { + $scope.counterText = response.data.counterText; + }, + function() { + }); + }; + }]); /** From 444e7821f6066a20ba7bc2f003f254991c873d47 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 9 Mar 2020 08:25:54 +0900 Subject: [PATCH 17/20] =?UTF-8?q?change:=20gjslint=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E4=BF=AE=E6=AD=A3=20https://github.com/NetCommons3/Ne?= =?UTF-8?q?tCommons3/issues/1560?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webroot/js/access_counters.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/webroot/js/access_counters.js b/webroot/js/access_counters.js index 61ac7ef..5c529b2 100644 --- a/webroot/js/access_counters.js +++ b/webroot/js/access_counters.js @@ -22,12 +22,12 @@ NetCommonsApp.controller('AccessCounters', $scope.initialize = function(frameId, counterText) { $scope.counterText = counterText; $http.get(NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId) - .then( - function(response) { - $scope.counterText = response.data.counterText; - }, - function() { - }); + .then( + function(response) { + $scope.counterText = response.data.counterText; + }, + function() { + }); }; }]); From 265c769f80ce693f80bca681f26078e1f0bf180d Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 9 Mar 2020 09:32:16 +0900 Subject: [PATCH 18/20] =?UTF-8?q?change:=20gjslint=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E4=BF=AE=E6=AD=A3=20https://github.com/NetCommons3/Ne?= =?UTF-8?q?tCommons3/issues/1560?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webroot/js/access_counters.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/webroot/js/access_counters.js b/webroot/js/access_counters.js index 5c529b2..d9e26ed 100644 --- a/webroot/js/access_counters.js +++ b/webroot/js/access_counters.js @@ -22,12 +22,11 @@ NetCommonsApp.controller('AccessCounters', $scope.initialize = function(frameId, counterText) { $scope.counterText = counterText; $http.get(NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId) - .then( - function(response) { - $scope.counterText = response.data.counterText; - }, - function() { - }); + .then(function(response) { + $scope.counterText = response.data.counterText; + }, + function() { + }); }; }]); From bfecf26ad409967c63326c75f855b3d0918a8518 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 9 Mar 2020 10:28:55 +0900 Subject: [PATCH 19/20] =?UTF-8?q?change:=20gjslint=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E4=BF=AE=E6=AD=A3=20https://github.com/NetCommons3/Ne?= =?UTF-8?q?tCommons3/issues/1560?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webroot/js/access_counters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webroot/js/access_counters.js b/webroot/js/access_counters.js index d9e26ed..2fe993f 100644 --- a/webroot/js/access_counters.js +++ b/webroot/js/access_counters.js @@ -22,7 +22,7 @@ NetCommonsApp.controller('AccessCounters', $scope.initialize = function(frameId, counterText) { $scope.counterText = counterText; $http.get(NC3_URL + '/access_counters/access_counters/view.json?frame_id=' + frameId) - .then(function(response) { + .then(function(response) { $scope.counterText = response.data.counterText; }, function() { From 93d963c30e6e3fcb6b7623b2b1d6d82a6681ef51 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 31 Jul 2020 21:43:19 +0900 Subject: [PATCH 20/20] =?UTF-8?q?change:=20test:=20traivs=E3=82=92?= =?UTF-8?q?=E5=AE=9F=E8=A1=8C=E3=81=99=E3=82=8B=E9=9A=9B=E3=81=ABavailabil?= =?UTF-8?q?ity=E3=81=AB=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4c82869..d2b765c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ dist: trusty env: matrix: - - NETCOMMONS_VERSION=master DB=mysql + - NETCOMMONS_VERSION=availability DB=mysql global: - secure: "PuEpJWVAx2BUVfp/lOEiuC5h3Ry1IckM0C+sKOJRRc/VcsPQYBQKTwiYBiVEbIA/1nMR+13+si57Ycb0p+Tagzyyn5SrNMScFM6jrUkk/5xiMDcH+h2Rc/fLlPapMtUSAeA37KZ+9fBN3sqw6KdT73N3ydfBrqOXFVURJhToNY8=" - GIT_COMMITTER_NAME=s-nakajima