From b781902da9e9e70d60c0aea8910edf048baa6cec Mon Sep 17 00:00:00 2001 From: Damir Abdullin Date: Tue, 26 Jul 2022 12:01:08 +0300 Subject: [PATCH] Remove tags/labels which doesn't have any relations (#861) --- .../repository/reactive/ReactiveLabelRepositoryImpl.java | 6 +++--- .../repository/reactive/ReactiveTagRepositoryImpl.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveLabelRepositoryImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveLabelRepositoryImpl.java index 14c51eba9..a569fb659 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveLabelRepositoryImpl.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveLabelRepositoryImpl.java @@ -43,7 +43,7 @@ public ReactiveLabelRepositoryImpl(final JooqReactiveOperations jooqReactiveOper @Override public Mono getDto(final long id) { final var query = DSL.select(LABEL.fields()) - .select(DSL.boolOr(LABEL_TO_DATASET_FIELD.EXTERNAL).as(EXTERNAL_FIELD)) + .select(DSL.coalesce(DSL.boolOr(LABEL_TO_DATASET_FIELD.EXTERNAL), false).as(EXTERNAL_FIELD)) .from(LABEL) .leftJoin(LABEL_TO_DATASET_FIELD).on(LABEL_TO_DATASET_FIELD.LABEL_ID.eq(LABEL.ID)) .where(idCondition(id)) @@ -56,7 +56,7 @@ public Mono getDto(final long id) { @Override public Mono> listDatasetFieldDtos(final Long datasetFieldId) { final var query = DSL.select(LABEL.fields()) - .select(DSL.boolOr(LABEL_TO_DATASET_FIELD.EXTERNAL).as(EXTERNAL_FIELD)) + .select(DSL.coalesce(DSL.boolOr(LABEL_TO_DATASET_FIELD.EXTERNAL), false).as(EXTERNAL_FIELD)) .from(LABEL) .leftJoin(LABEL_TO_DATASET_FIELD).on(LABEL_TO_DATASET_FIELD.LABEL_ID.eq(LABEL.ID)) .where(addSoftDeleteFilter(LABEL_TO_DATASET_FIELD.DATASET_FIELD_ID.eq(datasetFieldId))) @@ -80,7 +80,7 @@ public Mono> pageDto(final int page, final int size, final String final var cteSelect = DSL.with(labelCte.getName()) .as(select) .select(labelCte.fields()) - .select(DSL.boolOr(LABEL_TO_DATASET_FIELD.EXTERNAL).as(EXTERNAL_FIELD)) + .select(DSL.coalesce(DSL.boolOr(LABEL_TO_DATASET_FIELD.EXTERNAL), false).as(EXTERNAL_FIELD)) .from(labelCte.getName()) .leftJoin(LABEL_TO_DATASET_FIELD).on(LABEL_TO_DATASET_FIELD.LABEL_ID.eq(labelCte.field(LABEL.ID))) .groupBy(labelCte.fields()); diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveTagRepositoryImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveTagRepositoryImpl.java index 9e98f3a70..b3791ccd8 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveTagRepositoryImpl.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveTagRepositoryImpl.java @@ -46,7 +46,7 @@ public ReactiveTagRepositoryImpl(final JooqReactiveOperations jooqReactiveOperat public Mono getDto(final long id) { final var query = DSL.select(TAG.fields()) .select(DSL.count(TAG_TO_DATA_ENTITY.TAG_ID).as(COUNT_FIELD)) - .select(DSL.boolOr(TAG_TO_DATA_ENTITY.EXTERNAL).as(EXTERNAL_FIELD)) + .select(DSL.coalesce(DSL.boolOr(TAG_TO_DATA_ENTITY.EXTERNAL), false).as(EXTERNAL_FIELD)) .from(TAG) .leftJoin(TAG_TO_DATA_ENTITY).on(TAG_TO_DATA_ENTITY.TAG_ID.eq(TAG.ID)) .where(idCondition(id)) @@ -60,7 +60,7 @@ public Mono getDto(final long id) { public Mono> listDataEntityDtos(final Long dataEntityId) { final var query = DSL.select(TAG.fields()) .select(DSL.count(TAG_TO_DATA_ENTITY.TAG_ID).as(COUNT_FIELD)) - .select(DSL.boolOr(TAG_TO_DATA_ENTITY.EXTERNAL).as(EXTERNAL_FIELD)) + .select(DSL.coalesce(DSL.boolOr(TAG_TO_DATA_ENTITY.EXTERNAL), false).as(EXTERNAL_FIELD)) .from(TAG) .leftJoin(TAG_TO_DATA_ENTITY).on(TAG_TO_DATA_ENTITY.TAG_ID.eq(TAG.ID)) .where(addSoftDeleteFilter(TAG_TO_DATA_ENTITY.DATA_ENTITY_ID.eq(dataEntityId))) @@ -108,7 +108,7 @@ public Mono> listMostPopular(final String query, final List i final var cteSelect = DSL.with(tagCte.getName()) .as(select) .select(tagCte.fields()) - .select(DSL.boolOr(TAG_TO_DATA_ENTITY.EXTERNAL).as(EXTERNAL_FIELD)) + .select(DSL.coalesce(DSL.boolOr(TAG_TO_DATA_ENTITY.EXTERNAL), false).as(EXTERNAL_FIELD)) .select(DSL.count(TAG_TO_DATA_ENTITY.TAG_ID).as(COUNT_FIELD)) .from(tagCte.getName()) .leftJoin(TAG_TO_DATA_ENTITY).on(TAG_TO_DATA_ENTITY.TAG_ID.eq(tagCte.field(TAG.ID)))