This is an automated email from the ASF dual-hosted git repository. jsinovassinnaik pushed a commit to branch UNOMI-787-migrate-page-path in repository https://gitbox.apache.org/repos/asf/unomi.git
commit 195b7b2bae1afbea91392aeb0940f0f298a08de8 Author: jsinovassin <jsinovassinn...@jahia.com> AuthorDate: Thu Aug 10 18:37:24 2023 +0200 feedback + it tests --- .../unomi/itests/migration/Migrate16xTo220IT.java | 10 ++++++++++ .../resources/migration/snapshots_repository.zip | Bin 3886208 -> 3908941 bytes .../2.4.0/base_update_by_query_request.json | 5 +++++ .../2.4.0/view_event_page_path_migrate.painless | 7 ++++--- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/itests/src/test/java/org/apache/unomi/itests/migration/Migrate16xTo220IT.java b/itests/src/test/java/org/apache/unomi/itests/migration/Migrate16xTo220IT.java index 7dc321268..cddb44f49 100644 --- a/itests/src/test/java/org/apache/unomi/itests/migration/Migrate16xTo220IT.java +++ b/itests/src/test/java/org/apache/unomi/itests/migration/Migrate16xTo220IT.java @@ -98,6 +98,7 @@ public class Migrate16xTo220IT extends BaseIT { checkForMappingUpdates(); checkEventSessionRollover2_2_0(); checkIndexReductions2_2_0(); + checkPagePathForEventView(); } /** @@ -332,4 +333,13 @@ public class Migrate16xTo220IT extends BaseIT { JsonNode jsonNode = objectMapper.readTree(HttpUtils.executePostRequest(httpClient, "http://localhost:9400" + "/" + index + "/_count", requestBody, null)); return jsonNode.get("count").asInt(); } + + /** + * Data set contains 2 events that had a value in properties.path: + * The properties.path should have been moved to properties.pageInfo.pagePath + */ + private void checkPagePathForEventView() { + Assert.assertEquals(2, persistenceService.query("target.properties.pageInfo.pagePath", "/path/to/migrate/to/pageInfo", null, Event.class).size()); + Assert.assertEquals(0, persistenceService.query("properties.path", "/path/to/migrate/to/pageInfo", null, Event.class).size()); + } } diff --git a/itests/src/test/resources/migration/snapshots_repository.zip b/itests/src/test/resources/migration/snapshots_repository.zip index 38a4e9bfe..705a6241f 100644 Binary files a/itests/src/test/resources/migration/snapshots_repository.zip and b/itests/src/test/resources/migration/snapshots_repository.zip differ diff --git a/tools/shell-commands/src/main/resources/requestBody/2.4.0/base_update_by_query_request.json b/tools/shell-commands/src/main/resources/requestBody/2.4.0/base_update_by_query_request.json index d5244aed0..80399c8c9 100644 --- a/tools/shell-commands/src/main/resources/requestBody/2.4.0/base_update_by_query_request.json +++ b/tools/shell-commands/src/main/resources/requestBody/2.4.0/base_update_by_query_request.json @@ -15,6 +15,11 @@ "match": { "eventType": "view" } + }, + { + "exists": { + "field": "target.properties.path" + } } ] } diff --git a/tools/shell-commands/src/main/resources/requestBody/2.4.0/view_event_page_path_migrate.painless b/tools/shell-commands/src/main/resources/requestBody/2.4.0/view_event_page_path_migrate.painless index 358209f31..7ac82e437 100644 --- a/tools/shell-commands/src/main/resources/requestBody/2.4.0/view_event_page_path_migrate.painless +++ b/tools/shell-commands/src/main/resources/requestBody/2.4.0/view_event_page_path_migrate.painless @@ -16,8 +16,9 @@ */ if (ctx._source.target != null && ctx._source.target.properties != null && ctx._source.target.properties.path != null) { - if (ctx._source.target.properties.pageInfo != null) { - ctx._source.target.properties.pageInfo.pagePath = ctx._source.target.properties.path - ctx._source.target.properties.remove('path') + if (ctx._source.target.properties.pageInfo == null) { + ctx._source.target.properties.put('pageInfo', new HashMap()); } + ctx._source.target.properties.pageInfo.put('pagePath', ctx._source.target.properties.path); + ctx._source.target.properties.remove('path'); }