diff options
author | Peter Zhang <peter@innocraft.com> | 2022-06-07 04:55:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-07 04:55:47 +0300 |
commit | a81d55323a9c9a80694609ab131c9ce46f956f63 (patch) | |
tree | 48809a77d2f25e3f11557fe2ea144717cd7afd14 /plugins | |
parent | d036954668dcd4cf8cb4a5235cbed7519503d0f6 (diff) |
[UI]update invalid archive notification (#19126)
* update archive notification
update archive notification
* update condition
update condition
* update condition on message
update condition on message
* update error
update error
* Update _unprocessedSegmentMessage.twig
update unprocessed
* update screenshot
update screenshot
* update tests and some parts
update tests and some parts
* update phpcs error
update phpcs
* update tests
update tests
* update phpcs
update phpcs
* update screen shots
update screen shots
* Update plugins/SegmentEditor/lang/en.json
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* Update plugins/SegmentEditor/templates/_unprocessedSegmentMessage.twig
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* built vue files
* update tests ui screenshot
update tests ui screenshot
* update tests
update tests
* Update UnprocessedSegment_spec.js
update ui tests
* update tests
update tests
* update tests
update tests
* update tests
update tests
* Update UnprocessedSegment_spec.js
update tests
* Update UnprocessedSegment_spec.js
update tests
* set full config
set full config
* update screenshots
update screenshots
* update screeenshots
update screeenshots
* Rerun tests
Co-authored-by: Stefan Giehl <stefan@matomo.org>
Co-authored-by: peterhashair <peterhashair@users.noreply.github.com>
Co-authored-by: Ben <ben.burgess@innocraft.com>
Diffstat (limited to 'plugins')
7 files changed, 82 insertions, 31 deletions
diff --git a/plugins/SegmentEditor/SegmentEditor.php b/plugins/SegmentEditor/SegmentEditor.php index e3c9e16ea9..bd4e542a1e 100644 --- a/plugins/SegmentEditor/SegmentEditor.php +++ b/plugins/SegmentEditor/SegmentEditor.php @@ -18,18 +18,18 @@ use Piwik\Config; use Piwik\Container\StaticContainer; use Piwik\CronArchive\SegmentArchiving; use Piwik\DataAccess\ArchiveSelector; +use Piwik\Date; use Piwik\Notification; +use Piwik\Period; use Piwik\Piwik; use Piwik\Plugins\CoreHome\SystemSummary; use Piwik\Plugins\Diagnostics\Diagnostics; +use Piwik\Plugins\UsersManager\API as UsersManagerApi; use Piwik\Segment; use Piwik\SettingsServer; use Piwik\Site; -use Piwik\Period; use Piwik\Url; use Piwik\View; -use Piwik\Plugins\UsersManager\API as UsersManagerApi; -use Piwik\Date; /** */ @@ -194,7 +194,7 @@ class SegmentEditor extends \Piwik\Plugin return; } - list($segment, $storedSegment, $isSegmentToPreprocess) = $segmentInfo; + list($segment, $storedSegment, $isSegmentToPreprocess, $canBeArchived) = $segmentInfo; if (!$isSegmentToPreprocess) { return; // do not display the notification for custom segments @@ -205,6 +205,7 @@ class SegmentEditor extends \Piwik\Plugin $view = new View('@SegmentEditor/_unprocessedSegmentMessage.twig'); $view->isSegmentToPreprocess = $isSegmentToPreprocess; $view->segmentName = $segmentDisplayName; + $view->canBeArchived = $canBeArchived; $view->visitorLogLink = '#' . Url::getCurrentQueryStringWithParametersModified([ 'category' => 'General_Visitors', 'subcategory' => 'Live_VisitorLog', @@ -283,7 +284,20 @@ class SegmentEditor extends \Piwik\Plugin $storedSegment = null; } - return [$segment, $storedSegment, $isSegmentToPreprocess]; + // get the earliest date to rearchive + $earliestDateToRearchive = Piwik::getEarliestDateToRearchive(); + + //get the request end period + $endDate = $period->getDateEnd(); + $canBeArchived = true; + if (!empty($earliestDateToRearchive) && !empty($endDate)) { + //if the rearchive won't trigger + if ($earliestDateToRearchive->isLater($endDate)) { + $canBeArchived = false; + } + } + + return [$segment, $storedSegment, $isSegmentToPreprocess, $canBeArchived]; } public function install() diff --git a/plugins/SegmentEditor/lang/en.json b/plugins/SegmentEditor/lang/en.json index 932546ba61..363e128ec8 100644 --- a/plugins/SegmentEditor/lang/en.json +++ b/plugins/SegmentEditor/lang/en.json @@ -39,6 +39,7 @@ "SegmentOperatorIsNotNullNorEmpty": "is not null nor empty", "UnprocessedSegmentNoData1": "These reports have no data, because the Segment you requested %1$s has not yet been processed by the system.", "UnprocessedSegmentNoData2": "Data for this Segment should become available in a few hours when processing completes. (If it does not, there may be a problem.)", + "UnprocessedSegmentNoData3": "Matomo is unable to display data for the segment %1$s, as the configuration prevents a rearchiving for this period. Please contact your administrator or check %2$sthis FAQ%3$s how to solve this problem.", "UnprocessedSegmentInVisitorLog1": "%1$sMeanwhile you can use the Visitor Log%2$s to test whether your segment will match your users correctly by applying it there.", "UnprocessedSegmentInVisitorLog2": "When applied, you can see immediately which visits and actions were matched by your segment.", "UnprocessedSegmentInVisitorLog3": "This can help you confirm your Segment matches the users and actions you expect it to.", diff --git a/plugins/SegmentEditor/templates/_unprocessedSegmentMessage.twig b/plugins/SegmentEditor/templates/_unprocessedSegmentMessage.twig index 320590e787..43541107e0 100644 --- a/plugins/SegmentEditor/templates/_unprocessedSegmentMessage.twig +++ b/plugins/SegmentEditor/templates/_unprocessedSegmentMessage.twig @@ -1,17 +1,23 @@ {% set visitorLogLinkHtml %}<a href="{{ visitorLogLink }}" target="_blank">{% endset %} -{% if isSegmentToPreprocess %} -<p> - {{ 'SegmentEditor_UnprocessedSegmentNoData1'|translate('<strong>(' ~ segmentName ~ ')</strong>')|raw }} - {{ 'SegmentEditor_UnprocessedSegmentNoData2'|translate }} -</p> -{% else %} -<p> - {{ 'SegmentEditor_CustomUnprocessedSegmentApiError1'|translate }} - {{ 'SegmentEditor_CustomUnprocessedSegmentNoData'|translate }} -</p> -{% endif %} -<p> - {{ 'SegmentEditor_UnprocessedSegmentInVisitorLog1'|translate(visitorLogLinkHtml, '</a>')|raw }} - {{ 'SegmentEditor_UnprocessedSegmentInVisitorLog2'|translate }} - {{ 'SegmentEditor_UnprocessedSegmentInVisitorLog3'|translate }} -</p>
\ No newline at end of file + {% if isSegmentToPreprocess %} + {% if not canBeArchived %} + <p> + {{ 'SegmentEditor_UnprocessedSegmentNoData3'|translate('<strong>(' ~ segmentName ~ ')</strong>', '<a href="https://matomo.org/faq/troubleshooting/faq_141/" rel="noreferrer noopener">', '</a>')|raw }} + </p> + {% else %} + <p> + {{ 'SegmentEditor_UnprocessedSegmentNoData1'|translate('<strong>(' ~ segmentName ~ ')</strong>')|raw }} + {{ 'SegmentEditor_UnprocessedSegmentNoData2'|translate }} + </p> + {% endif %} + {% else %} + <p> + {{ 'SegmentEditor_CustomUnprocessedSegmentApiError1'|translate }} + {{ 'SegmentEditor_CustomUnprocessedSegmentNoData'|translate }} + </p> + {% endif %} + <p> + {{ 'SegmentEditor_UnprocessedSegmentInVisitorLog1'|translate(visitorLogLinkHtml, '</a>')|raw }} + {{ 'SegmentEditor_UnprocessedSegmentInVisitorLog2'|translate }} + {{ 'SegmentEditor_UnprocessedSegmentInVisitorLog3'|translate }} + </p> diff --git a/plugins/SegmentEditor/tests/UI/UnprocessedSegment_spec.js b/plugins/SegmentEditor/tests/UI/UnprocessedSegment_spec.js index f434389c0c..ab714529c3 100644 --- a/plugins/SegmentEditor/tests/UI/UnprocessedSegment_spec.js +++ b/plugins/SegmentEditor/tests/UI/UnprocessedSegment_spec.js @@ -10,7 +10,7 @@ describe("UnprocessedSegmentTest", function () { this.fixture = 'Piwik\\Tests\\Fixtures\\OneVisitorTwoVisits'; - var generalParams = 'idSite=1&period=day&date=2010-03-06'; + var generalParams = 'idSite=1&period=range&date=2010-03-06,2010-03-08'; var segment = 'browserCode==ff'; var customSegment = 'languageCode==fr'; var url = '?module=CoreHome&action=index&' + generalParams + '#?' + generalParams + '&category=General_Visitors&subcategory=General_Overview'; @@ -38,15 +38,42 @@ describe("UnprocessedSegmentTest", function () { await testEnvironment.callApi('SegmentEditor.delete', { idSegment: 1 }); }); + it('should not show a notification for custom segments that are not preprocessed', async function () { + + await page.goto(url + '&segment=' + encodeURIComponent(customSegment)); + + expect(await page.screenshotSelector('.pageWrap,#notificationContainer')).to.matchImage('custom_segment'); + }); + it("should show a notification for unprocessed segments", async function () { - await page.goto(url + '&segment=' + encodeURIComponent(segment)); + testEnvironment.configOverride.General = { + browser_archiving_disabled_enforce: '1', + enable_browser_archiving_triggering: '0', + rearchive_reports_in_past_last_n_months: '0', + }; + testEnvironment.optionsOverride = { + enableBrowserTriggerArchiving: '0', + }; + testEnvironment.save(); - expect(await page.screenshotSelector('.pageWrap,#notificationContainer')).to.matchImage('unprocessed_segment'); + await page.goto(url + '&segment=' + encodeURIComponent(segment)); + expect(await page.screenshotSelector('.pageWrap,#notificationContainer')).to.matchImage('unprocessed_default_segment'); }); - it('should not show a notification for custom segments that are not preprocessed', async function () { - await page.goto(url + '&segment=' + encodeURIComponent(customSegment)); - expect(await page.screenshotSelector('.pageWrap,#notificationContainer')).to.matchImage('custom_segment'); + it("should show a notification for unprocessed segments, caused by re archive date", async function () { + testEnvironment.configOverride.General = { + browser_archiving_disabled_enforce: '1', + enable_browser_archiving_triggering: '0', + rearchive_reports_in_past_last_n_months: '1', + }; + testEnvironment.optionsOverride = { + enableBrowserTriggerArchiving: '0', + }; + testEnvironment.save(); + + await page.goto(url + '&segment=' + encodeURIComponent(segment)); + + expect(await page.screenshotSelector('.pageWrap,#notificationContainer')).to.matchImage('unprocessed_segment'); }); }); diff --git a/plugins/SegmentEditor/tests/UI/expected-screenshots/UnprocessedSegmentTest_custom_segment.png b/plugins/SegmentEditor/tests/UI/expected-screenshots/UnprocessedSegmentTest_custom_segment.png index 471e634f93..7cfb510e24 100644 --- a/plugins/SegmentEditor/tests/UI/expected-screenshots/UnprocessedSegmentTest_custom_segment.png +++ b/plugins/SegmentEditor/tests/UI/expected-screenshots/UnprocessedSegmentTest_custom_segment.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:92f8bec901f7df700d9df069959da1df6b501b0538ec23ab01b436d42e49a052 -size 53532 +oid sha256:641278bb3bd9e3fc46cc5bb06dbb8a83008040be372cd558d17fa22dd8e4d63b +size 52459 diff --git a/plugins/SegmentEditor/tests/UI/expected-screenshots/UnprocessedSegmentTest_unprocessed_default_segment.png b/plugins/SegmentEditor/tests/UI/expected-screenshots/UnprocessedSegmentTest_unprocessed_default_segment.png new file mode 100644 index 0000000000..c52f40ab5e --- /dev/null +++ b/plugins/SegmentEditor/tests/UI/expected-screenshots/UnprocessedSegmentTest_unprocessed_default_segment.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5987249b6fcb83fcd8697b61a0f337c8cfc2278c7c156c6f64a065b832f63b9c +size 93500 diff --git a/plugins/SegmentEditor/tests/UI/expected-screenshots/UnprocessedSegmentTest_unprocessed_segment.png b/plugins/SegmentEditor/tests/UI/expected-screenshots/UnprocessedSegmentTest_unprocessed_segment.png index 115a019343..b5e7bfc8e6 100644 --- a/plugins/SegmentEditor/tests/UI/expected-screenshots/UnprocessedSegmentTest_unprocessed_segment.png +++ b/plugins/SegmentEditor/tests/UI/expected-screenshots/UnprocessedSegmentTest_unprocessed_segment.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8cd47dd1d1d646bf994cdc2c0b5944d80fda7b168b53b982a203937517366f1a -size 94566 +oid sha256:1b6023fd428f8077a88e27fbc61842cb6d9cbf0faea6350f18ee3541313c5ad5 +size 91781 |