diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2018-12-07 05:28:25 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2018-12-07 05:28:25 +0300 |
commit | 53c4d95a4b60ee099400db8c36ac64a68ffa37a3 (patch) | |
tree | 1a6918e045fb9d5a6fe35531854be98faafeb86f /plugins | |
parent | 6eb10a35e6388c62b88d77edc5055daa519de32d (diff) |
Some work on report totals (#13555)
* some work on totals
* fix graphs
* tweak rendering of totals row
* disable evolution for totals row
* let plugins configure totals row visibility
* remove metadata
* more tweaks and make it configurable
* improve code and performance
* fix some tests
* lots of improvements
* support bandwidth and other plugins
* fix tests
* add screenshot test
* also fix existing test
* add new method supportsTotalRow
* various fixes
* Updating some expected test files.
Diffstat (limited to 'plugins')
20 files changed, 189 insertions, 14 deletions
diff --git a/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentNames_lastN__API.getProcessedReport_day.xml b/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentNames_lastN__API.getProcessedReport_day.xml index 4af125d6bb..3626338034 100644 --- a/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentNames_lastN__API.getProcessedReport_day.xml +++ b/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentNames_lastN__API.getProcessedReport_day.xml @@ -86,7 +86,10 @@ <result prettyDate="Saturday, January 9, 2010" /> </reportMetadata> <reportTotal> - <nb_visits>16</nb_visits> <nb_uniq_visitors>16</nb_uniq_visitors> + <nb_visits>16</nb_visits> + <nb_impressions>18</nb_impressions> + <nb_interactions>6</nb_interactions> + <interaction_rate>33.33%</interaction_rate> </reportTotal> </result>
\ No newline at end of file diff --git a/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentPieces_lastN__API.getProcessedReport_day.xml b/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentPieces_lastN__API.getProcessedReport_day.xml index 3372acc13f..06ba5b5797 100644 --- a/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentPieces_lastN__API.getProcessedReport_day.xml +++ b/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentPieces_lastN__API.getProcessedReport_day.xml @@ -129,7 +129,10 @@ <result prettyDate="Saturday, January 9, 2010" /> </reportMetadata> <reportTotal> - <nb_visits>16</nb_visits> <nb_uniq_visitors>16</nb_uniq_visitors> + <nb_visits>16</nb_visits> + <nb_impressions>18</nb_impressions> + <nb_interactions>6</nb_interactions> + <interaction_rate>33.33%</interaction_rate> </reportTotal> </result>
\ No newline at end of file diff --git a/plugins/CoreHome/CoreHome.php b/plugins/CoreHome/CoreHome.php index ab11a468eb..f952b8508b 100644 --- a/plugins/CoreHome/CoreHome.php +++ b/plugins/CoreHome/CoreHome.php @@ -336,6 +336,8 @@ class CoreHome extends \Piwik\Plugin $translationKeys[] = 'CoreHome_ExternalHelp'; $translationKeys[] = 'CoreHome_ClickToEditX'; $translationKeys[] = 'CoreHome_Menu'; + $translationKeys[] = 'CoreHome_AddTotalsRowDataTable'; + $translationKeys[] = 'CoreHome_RemoveTotalsRowDataTable'; $translationKeys[] = 'SitesManager_NotFound'; $translationKeys[] = 'Annotations_ViewAndAddAnnotations'; $translationKeys[] = 'General_RowEvolutionRowActionTooltipTitle'; diff --git a/plugins/CoreHome/javascripts/dataTable.js b/plugins/CoreHome/javascripts/dataTable.js index 2570e24987..71852530a5 100644 --- a/plugins/CoreHome/javascripts/dataTable.js +++ b/plugins/CoreHome/javascripts/dataTable.js @@ -1294,6 +1294,13 @@ $.extend(DataTable.prototype, UIControl.prototype, { }) .click(generateClickCallback('flat')); + // handle flatten + $('.dataTableShowTotalsRow', domElem) + .each(function () { + setText(this, 'keep_totals_row', 'CoreHome_RemoveTotalsRowDataTable', 'CoreHome_AddTotalsRowDataTable'); + }) + .click(generateClickCallback('keep_totals_row')); + $('.dataTableIncludeAggregateRows', domElem) .each(function () { setText(this, 'include_aggregate_rows', 'CoreHome_DataTableExcludeAggregateRows', @@ -1975,6 +1982,7 @@ DataTable.registerFooterIconHandler('ecommerceAbandonedCart', switchToEcommerceV DataTable.switchToGraph = function (dataTable, viewDataTable) { var filters = dataTable.resetAllFilters(); dataTable.param.flat = filters.flat; + dataTable.param.keep_totals_row = filters.keep_totals_row; dataTable.param.columns = filters.columns; dataTable.param.viewDataTable = viewDataTable; diff --git a/plugins/CoreHome/javascripts/dataTable_rowactions.js b/plugins/CoreHome/javascripts/dataTable_rowactions.js index b937979cdf..7354f8ad1b 100644 --- a/plugins/CoreHome/javascripts/dataTable_rowactions.js +++ b/plugins/CoreHome/javascripts/dataTable_rowactions.js @@ -104,7 +104,7 @@ DataTable_RowActions_Registry.register({ }, isAvailableOnRow: function (dataTableParams, tr) { - return true; + return !tr.hasClass('totalsRow'); } }); diff --git a/plugins/CoreHome/lang/en.json b/plugins/CoreHome/lang/en.json index a74da65e9a..e0c8367cad 100644 --- a/plugins/CoreHome/lang/en.json +++ b/plugins/CoreHome/lang/en.json @@ -68,6 +68,8 @@ "TableNoData": "No data for this table.", "ThereIsNoDataForThisReport": "There is no data for this report.", "UnFlattenDataTable": "The report is flat %s Make it hierarchical", + "RemoveTotalsRowDataTable": "The report is showing the totals row %s Remove totals row", + "AddTotalsRowDataTable": "The report is not showing the totals row %s Show totals row", "ViewAllPiwikVideoTutorials": "View all Matomo Video Tutorials", "WebAnalyticsReports": "Web Analytics Reports", "YouAreUsingTheLatestVersion": "You are using the latest version of Matomo!", diff --git a/plugins/CoreHome/stylesheets/dataTable/_dataTable.less b/plugins/CoreHome/stylesheets/dataTable/_dataTable.less index a74d62b875..d15b3017a0 100644 --- a/plugins/CoreHome/stylesheets/dataTable/_dataTable.less +++ b/plugins/CoreHome/stylesheets/dataTable/_dataTable.less @@ -20,6 +20,13 @@ } } +table.dataTable .totalsRow { + font-weight: bold; + .ratio { + display: none; + } +} + table.dataTable td.label, table.subDataTable td.label { width: 100%; diff --git a/plugins/CoreHome/templates/_dataTableActions.twig b/plugins/CoreHome/templates/_dataTableActions.twig index 6ffed68619..3dc6c628be 100644 --- a/plugins/CoreHome/templates/_dataTableActions.twig +++ b/plugins/CoreHome/templates/_dataTableActions.twig @@ -114,6 +114,11 @@ <div class="configItem dataTableFlatten"></div> </li> {% endif %} + {% if not isDataTableEmpty and properties.show_totals_row|default(0) %} + <li> + <div class="configItem dataTableShowTotalsRow"></div> + </li> + {% endif %} {% if properties.show_exclude_low_population %} <li> <div class="configItem dataTableExcludeLowPopulation"></div> diff --git a/plugins/CoreHome/templates/_dataTableCell.twig b/plugins/CoreHome/templates/_dataTableCell.twig index d82a7bb851..a1b1c2c59a 100644 --- a/plugins/CoreHome/templates/_dataTableCell.twig +++ b/plugins/CoreHome/templates/_dataTableCell.twig @@ -12,7 +12,7 @@ {% endif %} {% set totals = dataTable.getMetadata('totals') %} -{% if column in totals|keys -%} +{% if column in properties.report_ratio_columns and column in totals|keys -%} {% set labelColumn = columns_to_display|first %} {% set reportTotal = totals[column] %} {% if siteSummary is defined and siteSummary is not empty and siteSummary.getFirstRow %} diff --git a/plugins/CoreVisualizations/Visualizations/HtmlTable.php b/plugins/CoreVisualizations/Visualizations/HtmlTable.php index 65866c8edf..adcf8e2bda 100644 --- a/plugins/CoreVisualizations/Visualizations/HtmlTable.php +++ b/plugins/CoreVisualizations/Visualizations/HtmlTable.php @@ -10,9 +10,9 @@ namespace Piwik\Plugins\CoreVisualizations\Visualizations; use Piwik\API\Request as ApiRequest; use Piwik\Common; +use Piwik\Metrics; use Piwik\Period; use Piwik\Plugin\Visualization; -use Piwik\View; /** * DataTable visualization that shows DataTable data in an HTML table. @@ -44,6 +44,19 @@ class HtmlTable extends Visualization $this->config->show_visualization_only = true; } + if ($this->requestConfig->idSubtable) { + $this->config->show_totals_row = false; + } + + foreach (Metrics::getMetricIdsToProcessReportTotal() as $metricId) { + $this->config->report_ratio_columns[] = Metrics::getReadableColumnName($metricId); + } + if (!empty($this->report)) { + foreach ($this->report->getMetricNamesToProcessReportTotals() as $metricName) { + $this->config->report_ratio_columns[] = $metricName; + } + } + // we do not want to get a datatable\map $period = Common::getRequestVar('period', 'day', 'string'); if (Period\Range::parseDateRange($period)) { diff --git a/plugins/CoreVisualizations/Visualizations/HtmlTable/Config.php b/plugins/CoreVisualizations/Visualizations/HtmlTable/Config.php index 9fa8163a6f..266a71e1b4 100644 --- a/plugins/CoreVisualizations/Visualizations/HtmlTable/Config.php +++ b/plugins/CoreVisualizations/Visualizations/HtmlTable/Config.php @@ -87,6 +87,19 @@ class Config extends VisualizationConfig */ public $highlight_summary_row = false; + /** + * If true, the totals row will be hidden + * + * Default value: false + */ + public $show_totals_row = true; + + /** + * A list of columns that support showing the ratio percentage on hover + * @var array + */ + public $report_ratio_columns = array(); + public function __construct() { parent::__construct(); diff --git a/plugins/CoreVisualizations/Visualizations/HtmlTable/RequestConfig.php b/plugins/CoreVisualizations/Visualizations/HtmlTable/RequestConfig.php index 2f674a5872..696569c618 100644 --- a/plugins/CoreVisualizations/Visualizations/HtmlTable/RequestConfig.php +++ b/plugins/CoreVisualizations/Visualizations/HtmlTable/RequestConfig.php @@ -29,6 +29,13 @@ class RequestConfig extends VisualizationRequestConfig */ public $keep_summary_row = false; + /** + * Controls whether the totals row is displayed on every page of the datatable view or not. + * + * Default value: false + */ + public $keep_totals_row = false; + public function __construct() { $this->filter_limit = PiwikConfig::getInstance()->General['datatable_default_limit']; @@ -49,11 +56,13 @@ class RequestConfig extends VisualizationRequestConfig 'filter_offset', 'filter_sort_column', 'filter_sort_order', - 'keep_summary_row' + 'keep_summary_row', + 'keep_totals_row' )); $this->addPropertiesThatCanBeOverwrittenByQueryParams(array( 'keep_summary_row', + 'keep_totals_row', )); } diff --git a/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable.twig b/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable.twig index a85ee66852..2d4a25e950 100644 --- a/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable.twig +++ b/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable.twig @@ -50,6 +50,18 @@ {% include "@CoreVisualizations/_dataTableViz_htmlTable.twig" with {'dataTable': row.getSubtable(), 'idSubtable': rowSubtableId} %} {% endif %} {%- endfor -%} + {% if dataTable.getTotalsRow and properties.show_totals_row %} + {% set row = dataTable.getTotalsRow %} + {% set rowId = 'totalsRow' %} + <tr class="{{ row.getMetadata('css_class') }} totalsRow" + title="Total values for this table"> + {% for column in properties.columns_to_display %} + <td> + {% include "@CoreHome/_dataTableCell.twig" with properties %} + </td> + {% endfor %} + </tr> + {% endif %} {% endif %} {%- if not showingEmbeddedSubtable -%} </tbody> diff --git a/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems_Metadata_ItemsCategory__API.getProcessedReport_day.xml b/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems_Metadata_ItemsCategory__API.getProcessedReport_day.xml index 697e009693..4937b4866b 100644 --- a/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems_Metadata_ItemsCategory__API.getProcessedReport_day.xml +++ b/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems_Metadata_ItemsCategory__API.getProcessedReport_day.xml @@ -108,8 +108,15 @@ </reportData> <reportMetadata /> <reportTotal> - <nb_visits>12</nb_visits> + <revenue>7111.22</revenue> + <quantity>18</quantity> + <price>4111.22</price> + <orders>8</orders> <nb_uniq_visitors>8</nb_uniq_visitors> + <nb_visits>12</nb_visits> <nb_actions>17</nb_actions> + <avg_price>513.9</avg_price> + <avg_quantity>2.3</avg_quantity> + <conversion_rate>66.67%</conversion_rate> </reportTotal> </result>
\ No newline at end of file diff --git a/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems_Metadata_ItemsSku__API.getProcessedReport_day.xml b/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems_Metadata_ItemsSku__API.getProcessedReport_day.xml index 7ec412b5c4..25b5f5768c 100644 --- a/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems_Metadata_ItemsSku__API.getProcessedReport_day.xml +++ b/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems_Metadata_ItemsSku__API.getProcessedReport_day.xml @@ -78,8 +78,15 @@ </reportData> <reportMetadata /> <reportTotal> - <nb_visits>6</nb_visits> + <revenue>3111.22</revenue> + <quantity>10</quantity> + <price>2111.22</price> + <orders>4</orders> <nb_uniq_visitors>3</nb_uniq_visitors> + <nb_visits>6</nb_visits> <nb_actions>11</nb_actions> + <avg_price>527.81</avg_price> + <avg_quantity>2.5</avg_quantity> + <conversion_rate>66.67%</conversion_rate> </reportTotal> </result>
\ No newline at end of file diff --git a/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems_Metadata_VisitTime.getVisitInformationPerServerTime__API.getProcessedReport_day.xml b/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems_Metadata_VisitTime.getVisitInformationPerServerTime__API.getProcessedReport_day.xml index f4fea49b13..1f571c5f87 100644 --- a/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems_Metadata_VisitTime.getVisitInformationPerServerTime__API.getProcessedReport_day.xml +++ b/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems_Metadata_VisitTime.getVisitInformationPerServerTime__API.getProcessedReport_day.xml @@ -394,12 +394,42 @@ </row> </reportMetadata> <reportTotal> - <nb_visits>3</nb_visits> <nb_uniq_visitors>3</nb_uniq_visitors> + <nb_visits>3</nb_visits> <nb_actions>13</nb_actions> - <nb_conversions>3</nb_conversions> + <nb_users>0</nb_users> + <max_actions>6</max_actions> + <sum_visit_length>5403</sum_visit_length> <bounce_count>0</bounce_count> + <goals> + <row idgoal="1"> + <nb_conversions>1</nb_conversions> + <nb_visits_converted>1</nb_visits_converted> + <revenue>10</revenue> + </row> + <row idgoal="ecommerceAbandonedCart"> + <nb_conversions>2</nb_conversions> + <nb_visits_converted>2</nb_visits_converted> + <revenue>5020.22</revenue> + <items>8</items> + </row> + <row idgoal="ecommerceOrder"> + <nb_conversions>2</nb_conversions> + <nb_visits_converted>1</nb_visits_converted> + <revenue>3111.11</revenue> + <revenue_subtotal>2500</revenue_subtotal> + <revenue_tax>511</revenue_tax> + <revenue_shipping>100.11</revenue_shipping> + <revenue_discount>666</revenue_discount> + <items>10</items> + </row> + </goals> + <nb_conversions>3</nb_conversions> <revenue>3121.11</revenue> <nb_visits_converted>0</nb_visits_converted> + <conversion_rate>0%</conversion_rate> + <nb_actions_per_visit>4.3</nb_actions_per_visit> + <avg_time_on_site>1801</avg_time_on_site> + <bounce_rate>0%</bounce_rate> </reportTotal> </result>
\ No newline at end of file diff --git a/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems__API.getProcessedReport_day.xml b/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems__API.getProcessedReport_day.xml index 8019f8be6b..5cdd1dbbc3 100644 --- a/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems__API.getProcessedReport_day.xml +++ b/plugins/Ecommerce/tests/System/expected/test_ecommerceOrderWithItems__API.getProcessedReport_day.xml @@ -87,11 +87,41 @@ </row> </reportMetadata> <reportTotal> - <nb_visits>3</nb_visits> <nb_uniq_visitors>2</nb_uniq_visitors> + <nb_visits>3</nb_visits> <nb_actions>13</nb_actions> - <nb_conversions>3</nb_conversions> + <nb_users>0</nb_users> + <max_actions>6</max_actions> + <sum_visit_length>5403</sum_visit_length> <bounce_count>0</bounce_count> + <goals> + <row idgoal="1"> + <nb_conversions>1</nb_conversions> + <nb_visits_converted>1</nb_visits_converted> + <revenue>10</revenue> + </row> + <row idgoal="ecommerceAbandonedCart"> + <nb_conversions>2</nb_conversions> + <nb_visits_converted>2</nb_visits_converted> + <revenue>5020.22</revenue> + <items>8</items> + </row> + <row idgoal="ecommerceOrder"> + <nb_conversions>2</nb_conversions> + <nb_visits_converted>1</nb_visits_converted> + <revenue>3111.11</revenue> + <revenue_subtotal>2500</revenue_subtotal> + <revenue_tax>511</revenue_tax> + <revenue_shipping>100.11</revenue_shipping> + <revenue_discount>666</revenue_discount> + <items>10</items> + </row> + </goals> + <nb_conversions>3</nb_conversions> <revenue>3121.11</revenue> + <conversion_rate>0%</conversion_rate> + <nb_actions_per_visit>4.3</nb_actions_per_visit> + <avg_time_on_site>1801</avg_time_on_site> + <bounce_rate>0%</bounce_rate> </reportTotal> </result>
\ No newline at end of file diff --git a/plugins/Goals/Visualizations/Goals.php b/plugins/Goals/Visualizations/Goals.php index 4453b2f352..2fd5a35200 100644 --- a/plugins/Goals/Visualizations/Goals.php +++ b/plugins/Goals/Visualizations/Goals.php @@ -8,8 +8,10 @@ namespace Piwik\Plugins\Goals\Visualizations; +use Piwik\API\DataTablePostProcessor; use Piwik\API\Request; use Piwik\Common; +use Piwik\DataTable; use Piwik\DataTable\Filter\AddColumnsProcessedMetricsGoal; use Piwik\Piwik; use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable; @@ -32,6 +34,8 @@ class Goals extends HtmlTable { parent::beforeLoadDataTable(); + $this->config->show_totals_row = false; + if ($this->config->disable_subtable_when_show_goals) { $this->config->subtable_controller_action = null; } @@ -41,6 +45,7 @@ class Goals extends HtmlTable public function beforeRender() { + $this->config->show_totals_row = false; $this->config->show_goals = true; $this->config->show_goals_columns = true; $this->config->datatable_css_class = 'dataTableVizGoals'; diff --git a/plugins/Referrers/tests/System/expected/test_Referrers_getReferrerType__API.getProcessedReport_day.xml b/plugins/Referrers/tests/System/expected/test_Referrers_getReferrerType__API.getProcessedReport_day.xml index 899efa34f5..fd8d54cdbc 100644 --- a/plugins/Referrers/tests/System/expected/test_Referrers_getReferrerType__API.getProcessedReport_day.xml +++ b/plugins/Referrers/tests/System/expected/test_Referrers_getReferrerType__API.getProcessedReport_day.xml @@ -1189,12 +1189,31 @@ <result prettyDate="Wednesday, March 10, 2010" /> </reportMetadata> <reportTotal> - <nb_visits>62</nb_visits> <nb_uniq_visitors>62</nb_uniq_visitors> + <nb_visits>62</nb_visits> <nb_actions>62</nb_actions> - <nb_visits_converted>0</nb_visits_converted> + <nb_users>0</nb_users> + <max_actions>31</max_actions> + <sum_visit_length>11315</sum_visit_length> <bounce_count>62</bounce_count> + <nb_visits_converted>0</nb_visits_converted> + <goals> + <row idgoal="1"> + <nb_conversions>1</nb_conversions> + <nb_visits_converted>1</nb_visits_converted> + <revenue>0</revenue> + </row> + <row idgoal="2"> + <nb_conversions>2</nb_conversions> + <nb_visits_converted>1</nb_visits_converted> + <revenue>0</revenue> + </row> + </goals> <nb_conversions>93</nb_conversions> <revenue>0</revenue> + <conversion_rate>0</conversion_rate> + <nb_actions_per_visit>31</nb_actions_per_visit> + <avg_time_on_site>5673</avg_time_on_site> + <bounce_rate>3100</bounce_rate> </reportTotal> </result>
\ No newline at end of file diff --git a/plugins/Referrers/tests/System/expected/test_phpSerialized__Referrers.getReferrerType_year.original b/plugins/Referrers/tests/System/expected/test_phpSerialized__Referrers.getReferrerType_year.original Binary files differindex b032811929..a40b85791c 100644 --- a/plugins/Referrers/tests/System/expected/test_phpSerialized__Referrers.getReferrerType_year.original +++ b/plugins/Referrers/tests/System/expected/test_phpSerialized__Referrers.getReferrerType_year.original |