From 5e030eb12649a46758f5d08a15fcef609c1e4202 Mon Sep 17 00:00:00 2001 From: Jason Mayo Date: Fri, 4 Jan 2019 15:56:01 +0000 Subject: [PATCH] MySQL 5.7 fixes and tweaks to other widgets --- CHANGELOG.md | 9 ++ composer.json | 2 +- releases.json | 136 ++++++++---------- src/models/Settings.php | 5 +- .../widgets/ProductsRecent/body.twig | 6 + src/templates/widgets/ProductsTop/body.twig | 2 +- .../widgets/SubscriptionPlans/body.twig | 6 + src/widgets/CartAbandonment.php | 4 +- src/widgets/Goal.php | 2 +- src/widgets/ProductsTop.php | 2 +- src/widgets/SubscriptionPlans.php | 2 +- src/widgets/TopCustomers.php | 2 +- 12 files changed, 91 insertions(+), 87 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ec56c2..01a08b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Commerce Widgets Changelog +## 2.0.10 - 2019-01-04 +### Fixed +- `groupBy` issue with MySQL 5.7 on some widgets +- Week was showing incorrectly in the Goal widget +- Installing the plugin now populates the cache setting by default + +### Changed +- When no elements exist on a widget they now show a message + ## 2.0.9 - 2018-10-30 ### Added - *New Widget* Top Products Widget - See your top products ordered by Revenue or # Ordered diff --git a/composer.json b/composer.json index 0e21b36..c8353d8 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "bymayo/commerce-widgets", "description": "Insightful dashboard widgets for your Craft Commerce 2 store.", "type": "craft-plugin", - "version": "2.0.9", + "version": "2.0.10", "keywords": [ "craft", "cms", diff --git a/releases.json b/releases.json index 12753e4..898e926 100644 --- a/releases.json +++ b/releases.json @@ -1,78 +1,62 @@ [ -{ - "version": "1.0.8", - "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/craft-2.zip", - "date": "2018-10-30T13:25:28.418Z", - "notes": [ - "[Fixed] Completed carts figure incorrect - https://github.com/bymayo/craft-commerce-widgets/issues/11" - ] -} - { - "version": "1.0.7", - "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/craft-2.zip", - "date": "2018-05-25T13:25:28.418Z", - "notes": [ - "[Improved] Updated Icons & Branding" - ] - }, - { - "version": "1.0.6", - "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/craft-2.zip", - "date": "2018-03-08T17:03:00+00:00", - "notes": [ - "[Added] Added 'All' to TotalRevenueOrdersWidget", - "[Improved] Moved Craft 2 version to seperate branch (Craft 3 version coming soon...)" - ] - }, - { - "version": "1.0.5", - "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/master.zip", - "date": "2017-02-09T17:03:00+00:00", - "notes": [ - "[Fixed] Incorrect limit on Cart Abadonment widget (Thanks terryupton! [Again!])", - "[Improved] Removed left over debugging in JS", - "[Improved] Changed colour of Cart Abanadoment widget chart" - ] - }, - { - "version": "1.0.4", - "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/master.zip", - "date": "2017-02-09T17:03:00+00:00", - "notes": [ - "[Fixed] Incorrect year on Total Revenue widget (Thanks terryupton!)" - ] - }, - { - "version": "1.0.3", - "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/master.zip", - "date": "2016-09-19T17:03:00+00:00", - "notes": [ - "[Added] Top Customers widget" - ] - }, - { - "version": "1.0.2", - "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/master.zip", - "date": "2016-09-19T11:57:00+00:00", - "notes": [ - "[Improved] Cart Abanadonment widget graph now has a 'No Results' state" - ] - }, - { - "version": "1.0.1", - "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/master.zip", - "date": "2016-09-19T11:42:00+00:00", - "notes": [ - "[Fixed] Fixed Cart Abandonment widget numbers", - "[Improved] Cart Abandonment widget colours. Now easier to see which value is completed" - ] - }, - { - "version": "1.0.0", - "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/master.zip", - "date": "2016-09-02T19:42:00+00:00", - "notes": [ - "[Added] Initial release" - ] - } + { + "version": "1.0.6", + "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/craft-2.zip", + "date": "2018-03-08T17:03:00+00:00", + "notes": [ + "[Added] Added 'All' to TotalRevenueOrdersWidget", + "[Improved] Moved Craft 2 version to seperate branch (Craft 3 version coming soon...)" + ] + }, + { + "version": "1.0.5", + "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/master.zip", + "date": "2017-02-09T17:03:00+00:00", + "notes": [ + "[Fixed] Incorrect limit on Cart Abadonment widget (Thanks terryupton! [Again!])", + "[Improved] Removed left over debugging in JS", + "[Improved] Changed colour of Cart Abanadoment widget chart" + ] + }, + { + "version": "1.0.4", + "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/master.zip", + "date": "2017-02-09T17:03:00+00:00", + "notes": [ + "[Fixed] Incorrect year on Total Revenue widget (Thanks terryupton!)" + ] + }, + { + "version": "1.0.3", + "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/master.zip", + "date": "2016-09-19T17:03:00+00:00", + "notes": [ + "[Added] Top Customers widget" + ] + }, + { + "version": "1.0.2", + "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/master.zip", + "date": "2016-09-19T11:57:00+00:00", + "notes": [ + "[Improved] Cart Abanadonment widget graph now has a 'No Results' state" + ] + }, + { + "version": "1.0.1", + "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/master.zip", + "date": "2016-09-19T11:42:00+00:00", + "notes": [ + "[Fixed] Fixed Cart Abandonment widget numbers", + "[Improved] Cart Abandonment widget colours. Now easier to see which value is completed" + ] + }, + { + "version": "1.0.0", + "downloadUrl": "https://github.com/bymayo/commerce-widgets/archive/master.zip", + "date": "2016-09-02T19:42:00+00:00", + "notes": [ + "[Added] Initial release" + ] + } ] diff --git a/src/models/Settings.php b/src/models/Settings.php index d6d35ec..392ceca 100755 --- a/src/models/Settings.php +++ b/src/models/Settings.php @@ -28,7 +28,7 @@ class Settings extends Model /** * @var string */ - public $cacheDuration; + public $cacheDuration = 3600; // Public Methods // ========================================================================= @@ -39,8 +39,7 @@ class Settings extends Model public function rules() { return [ - ['cacheDuration', 'integer'], - ['cacheDuration', 'default', 'value' => 3600] + ['cacheDuration', 'integer'] ]; } } diff --git a/src/templates/widgets/ProductsRecent/body.twig b/src/templates/widgets/ProductsRecent/body.twig index 6ae3e9a..5ef3c29 100755 --- a/src/templates/widgets/ProductsRecent/body.twig +++ b/src/templates/widgets/ProductsRecent/body.twig @@ -30,6 +30,12 @@ {{ product.defaultPrice|currency(commerce.currency) }} + {% else %} + + + No products found. + + {% endfor %} diff --git a/src/templates/widgets/ProductsTop/body.twig b/src/templates/widgets/ProductsTop/body.twig index 4e2e9d5..3d8e33f 100644 --- a/src/templates/widgets/ProductsTop/body.twig +++ b/src/templates/widgets/ProductsTop/body.twig @@ -40,7 +40,7 @@ {% else %} - + No products found. diff --git a/src/templates/widgets/SubscriptionPlans/body.twig b/src/templates/widgets/SubscriptionPlans/body.twig index b9db936..0b4395c 100644 --- a/src/templates/widgets/SubscriptionPlans/body.twig +++ b/src/templates/widgets/SubscriptionPlans/body.twig @@ -26,6 +26,12 @@ {{ plan.activeSubscriptions|number_format() }} + {% else %} + + + No subscriptions found. + + {% endfor %} diff --git a/src/widgets/CartAbandonment.php b/src/widgets/CartAbandonment.php index 8ea516d..7d09375 100755 --- a/src/widgets/CartAbandonment.php +++ b/src/widgets/CartAbandonment.php @@ -93,8 +93,8 @@ public function getTotalCarts($isCompleted) 'orders.isCompleted' => $isCompleted ] ) - ->groupBy('month') - ->orderBy('month'); + ->groupBy(['orders.dateCreated']) + ->orderBy('orders.dateCreated'); $command = $query->createCommand(); $result = $command->cache(CommerceWidgets::$plugin->getSettings()->cacheDuration)->queryAll(); diff --git a/src/widgets/Goal.php b/src/widgets/Goal.php index 324cd4c..871027c 100755 --- a/src/widgets/Goal.php +++ b/src/widgets/Goal.php @@ -75,7 +75,7 @@ public function getTotals() $query ->where( [ - 'WEEK(orders.datePaid)' => date('W'), + 'WEEK(orders.datePaid, 1)' => date('W'), 'YEAR(orders.datePaid)' => date('Y') ] ); diff --git a/src/widgets/ProductsTop.php b/src/widgets/ProductsTop.php index ba5dbaf..55aa301 100644 --- a/src/widgets/ProductsTop.php +++ b/src/widgets/ProductsTop.php @@ -69,7 +69,7 @@ public function getProducts() ->join( 'LEFT JOIN', '{{%commerce_variants}} variants', 'variants.id = purchasables.id' ) - ->groupBy('items.purchasableId') + ->groupBy(['items.purchasableId']) ->orderBy($this->orderBy . ' desc') ->limit($this->limit); diff --git a/src/widgets/SubscriptionPlans.php b/src/widgets/SubscriptionPlans.php index 157b65c..87ce857 100644 --- a/src/widgets/SubscriptionPlans.php +++ b/src/widgets/SubscriptionPlans.php @@ -75,7 +75,7 @@ public function getSubscriptionPlans() 'plans.isArchived' => 0 ] ) - ->groupBy('plans.id') + ->groupBy(['plans.id']) ->orderBy($this->orderBy) ->limit($this->limit); diff --git a/src/widgets/TopCustomers.php b/src/widgets/TopCustomers.php index fe07b53..8360643 100755 --- a/src/widgets/TopCustomers.php +++ b/src/widgets/TopCustomers.php @@ -69,7 +69,7 @@ public function getCustomers() ->from(['orders' => '{{%commerce_orders}}']) ->where(['orders.isCompleted' => 1]) ->orderBy($this->orderBy . ' desc') - ->groupBy(['orders.email']) + ->groupBy(['orders.email', 'orders.customerId']) ->limit(5); if($this->includeGuests == 'no')