From e72244850d585aecbfbcc8d501416f4aed7a468c Mon Sep 17 00:00:00 2001 From: brig Date: Mon, 13 Nov 2023 13:44:57 +0100 Subject: [PATCH] nullable project, repo, ord for user cards --- .../walmartlabs/concord/server/db/v2.1.0.xml | 1 - .../server/console/ProcessCardEntry.java | 4 ++++ .../server/console/ProcessCardResource.java | 20 ++++++++++++++++ .../console/UserActivityResourceV2.java | 24 ++++++++++++------- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/server/db/src/main/resources/com/walmartlabs/concord/server/db/v2.1.0.xml b/server/db/src/main/resources/com/walmartlabs/concord/server/db/v2.1.0.xml index f87f6505d1..3d13ec7bc6 100644 --- a/server/db/src/main/resources/com/walmartlabs/concord/server/db/v2.1.0.xml +++ b/server/db/src/main/resources/com/walmartlabs/concord/server/db/v2.1.0.xml @@ -103,5 +103,4 @@ - diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/console/ProcessCardEntry.java b/server/impl/src/main/java/com/walmartlabs/concord/server/console/ProcessCardEntry.java index 77d97adc42..a4f1092772 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/console/ProcessCardEntry.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/console/ProcessCardEntry.java @@ -43,15 +43,19 @@ public interface ProcessCardEntry extends Serializable { UUID id(); @ConcordKey + @Nullable String orgName(); @ConcordKey + @Nullable String projectName(); @ConcordKey + @Nullable String repoName(); @Size(max = 256) + @Nullable String entryPoint(); @Size(max = 128) diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/console/ProcessCardResource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/console/ProcessCardResource.java index 5a861eb1b8..8a2abb8b9c 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/console/ProcessCardResource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/console/ProcessCardResource.java @@ -1,5 +1,25 @@ package com.walmartlabs.concord.server.console; +/*- + * ***** + * Concord + * ----- + * Copyright (C) 2017 - 2023 Walmart Inc. + * ----- + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ===== + */ + import com.walmartlabs.concord.common.IOUtils; import com.walmartlabs.concord.common.validation.ConcordKey; import com.walmartlabs.concord.db.AbstractDao; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/console/UserActivityResourceV2.java b/server/impl/src/main/java/com/walmartlabs/concord/server/console/UserActivityResourceV2.java index c57953cb6e..1e15fe8b8b 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/console/UserActivityResourceV2.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/console/UserActivityResourceV2.java @@ -227,9 +227,9 @@ private static Optional getInputStream(DSLContext tx, String sql, UUID ca public List listCards(DSLContext tx, UUID userId) { // TODO: V_USER_TEAMS - SelectConditionStep> userTeams = tx.select(USER_TEAMS.TEAM_ID) - .from(USER_TEAMS) - .where(USER_TEAMS.USER_ID.eq(userId)); + SelectConditionStep> userTeams = tx.select(V_USER_TEAMS.TEAM_ID) + .from(V_USER_TEAMS) + .where(V_USER_TEAMS.USER_ID.eq(userId)); SelectConditionStep> byUserFilter = tx.select(USER_UI_PROCESS_CARDS.UI_PROCESS_CARD_ID) .from(USER_UI_PROCESS_CARDS) @@ -239,12 +239,18 @@ public List listCards(DSLContext tx, UUID userId) { .from(TEAM_UI_PROCESS_CARDS) .where(TEAM_UI_PROCESS_CARDS.TEAM_ID.in(userTeams)); + SelectOrderByStep> userCards = byUserFilter.unionAll(byTeamFilter); + + SelectJoinStep> userCardsFilter = tx.select(userCards.field(TEAM_UI_PROCESS_CARDS.UI_PROCESS_CARD_ID)) + .from(userCards); + SelectConditionStep> query = buildSelect(tx) - .where(UI_PROCESS_CARDS.UI_PROCESS_CARD_ID.in(byUserFilter) - .or(UI_PROCESS_CARDS.UI_PROCESS_CARD_ID.in(byTeamFilter))); + .where(UI_PROCESS_CARDS.UI_PROCESS_CARD_ID.in(userCardsFilter)); - return query.fetch(this::toEntry); + return query + .orderBy(UI_PROCESS_CARDS.UI_PROCESS_CARD_ID) + .fetch(this::toEntry); } private static SelectOnConditionStep> buildSelect(DSLContext tx) { @@ -265,9 +271,9 @@ private static SelectOnConditionStep r) {