Skip to content

Commit

Permalink
Remove tags/labels which doesn't have any relations (#861)
Browse files Browse the repository at this point in the history
  • Loading branch information
damirabdul authored Jul 26, 2022
1 parent 999804f commit b781902
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ReactiveLabelRepositoryImpl(final JooqReactiveOperations jooqReactiveOper
@Override
public Mono<LabelDto> 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))
Expand All @@ -56,7 +56,7 @@ public Mono<LabelDto> getDto(final long id) {
@Override
public Mono<List<LabelDto>> 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)))
Expand All @@ -80,7 +80,7 @@ public Mono<Page<LabelDto>> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ReactiveTagRepositoryImpl(final JooqReactiveOperations jooqReactiveOperat
public Mono<TagDto> 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))
Expand All @@ -60,7 +60,7 @@ public Mono<TagDto> getDto(final long id) {
public Mono<List<TagDto>> 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)))
Expand Down Expand Up @@ -108,7 +108,7 @@ public Mono<Page<TagDto>> listMostPopular(final String query, final List<Long> 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)))
Expand Down

0 comments on commit b781902

Please sign in to comment.