diff --git a/.github/workflows/cli-testing.yml b/.github/workflows/cli-testing.yml index 7608eabff..b5a603d7b 100644 --- a/.github/workflows/cli-testing.yml +++ b/.github/workflows/cli-testing.yml @@ -31,8 +31,8 @@ jobs: - name: Build and Load API Docker Image uses: useblacksmith/build-push-action@v1 with: - context: ./api - file: ./api/Dockerfile + context: ./apps/api + file: ./apps/api/Dockerfile push: false # Do not push, load locally for service container load: true # Load the image into the runner's Docker daemon tags: local-api-test:latest # Tag for the service definition diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 85f346aea..315a04697 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -103,8 +103,8 @@ jobs: - name: Build and push API image uses: useblacksmith/build-push-action@v1 with: - context: ./api - file: ./api/Dockerfile + context: ./apps/api + file: ./apps/api/Dockerfile push: true platforms: ${{ matrix.docker_platform }} tags: | @@ -199,4 +199,4 @@ jobs: else echo "Failed to set package $ORG_NAME/${{ env.WEB_IMAGE_NAME }} visibility to public. HTTP Status: $RESPONSE_CODE" # Optionally, fail the step: exit 1 - fi \ No newline at end of file + fi diff --git a/.github/workflows/web-e2e-tests-optimized.yml b/.github/workflows/web-e2e-tests-optimized.yml index cfdeea73c..e7885d6f7 100644 --- a/.github/workflows/web-e2e-tests-optimized.yml +++ b/.github/workflows/web-e2e-tests-optimized.yml @@ -69,8 +69,8 @@ jobs: - name: Build & Load API Docker Image uses: useblacksmith/build-push-action@v1 with: - context: ./api - file: ./api/Dockerfile + context: ./apps/api + file: ./apps/api/Dockerfile push: false load: true tags: local-api-test:latest @@ -199,4 +199,4 @@ jobs: if: always() run: | docker stop local-api - docker rm local-api \ No newline at end of file + docker rm local-api diff --git a/apps/api/libs/handlers/src/chats/list_chats_handler.rs b/apps/api/libs/handlers/src/chats/list_chats_handler.rs index 5701d6192..a0fdd824d 100644 --- a/apps/api/libs/handlers/src/chats/list_chats_handler.rs +++ b/apps/api/libs/handlers/src/chats/list_chats_handler.rs @@ -78,7 +78,7 @@ pub async fn list_chats_handler( request: ListChatsRequest, user: &AuthenticatedUser, ) -> Result> { - use database::schema::{asset_permissions, chats, users}; + use database::schema::{asset_permissions, chats, messages, users}; let mut conn = get_pg_pool().get().await?; @@ -106,6 +106,18 @@ pub async fn list_chats_handler( .inner_join(users::table.on(chats::created_by.eq(users::id))) .filter(chats::deleted_at.is_null()) .filter(chats::title.ne("")) // Filter out empty titles + .filter( + diesel::dsl::exists( + messages::table + .filter(messages::chat_id.eq(chats::id)) + .filter(messages::request_message.is_not_null()) + .filter(messages::deleted_at.is_null()) + ).or( + diesel::dsl::sql::( + "(SELECT COUNT(*) FROM messages WHERE messages.chat_id = chats.id AND messages.deleted_at IS NULL) > 1" + ) + ) + ) .into_boxed(); // Add user filter if not admin view @@ -173,4 +185,4 @@ pub async fn list_chats_handler( }; Ok(items) -} \ No newline at end of file +} diff --git a/apps/api/libs/handlers/src/logs/list_logs_handler.rs b/apps/api/libs/handlers/src/logs/list_logs_handler.rs index 4ce45bf8e..09d65fabe 100644 --- a/apps/api/libs/handlers/src/logs/list_logs_handler.rs +++ b/apps/api/libs/handlers/src/logs/list_logs_handler.rs @@ -69,7 +69,7 @@ pub async fn list_logs_handler( request: ListLogsRequest, organization_id: Uuid, ) -> Result { - use database::schema::{chats, users}; + use database::schema::{chats, messages, users}; let mut conn = get_pg_pool().get().await?; @@ -80,6 +80,18 @@ pub async fn list_logs_handler( .filter(chats::organization_id.eq(organization_id)) .filter(chats::title.ne("")) // Filter out empty titles .filter(chats::title.ne(" ")) // Filter out single space + .filter( + diesel::dsl::exists( + messages::table + .filter(messages::chat_id.eq(chats::id)) + .filter(messages::request_message.is_not_null()) + .filter(messages::deleted_at.is_null()) + ).or( + diesel::dsl::sql::( + "(SELECT COUNT(*) FROM messages WHERE messages.chat_id = chats.id AND messages.deleted_at IS NULL) > 1" + ) + ) + ) .into_boxed(); // Calculate offset based on page number