From ea5162f61f175215ac216a16032ed422eccfd92d Mon Sep 17 00:00:00 2001 From: Florinda Date: Tue, 19 Nov 2024 10:19:58 +0100 Subject: [PATCH] filter exec list --- .../hermione/repository/ScenarioExecutionRepository.java | 8 +++++--- .../hermione/services/ScenarioExecutionService.java | 5 +++-- src/main/resources/application.properties | 7 +++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/olympus/hermione/repository/ScenarioExecutionRepository.java b/src/main/java/com/olympus/hermione/repository/ScenarioExecutionRepository.java index 60ba589..6c7e3b6 100644 --- a/src/main/java/com/olympus/hermione/repository/ScenarioExecutionRepository.java +++ b/src/main/java/com/olympus/hermione/repository/ScenarioExecutionRepository.java @@ -2,6 +2,7 @@ package com.olympus.hermione.repository; import java.util.List; +import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.Query; import org.springframework.stereotype.Repository; @@ -21,10 +22,11 @@ public interface ScenarioExecutionRepository extends MongoRepository findByExecutedByUserIdAndInputs(String userId, String selectedProject, String selectedApplication); @Query("{ $and: [ { 'executedByUserId': ?0 }, { 'scenarioExecutionInput.inputs.selected_project': ?1 }, { 'scenarioExecutionInput.inputs.selected_application': ?2 } ] }") - List findByExecutedByUserIdAndInputsOrderByStartDateDesc(String userId, String value1, String value2); + List getFromProjectAndAPP(String userId, String value1, String value2, Sort sort); + //findByExecutedByUserIdAndInputsOrderByStartDateDesc - @Query("{ $and: [ { 'executedByUserId': ?0 }, { 'scenarioExecutionInput.inputs.selected_project': ?1 }") - List findByExecutedByUserIdAndSingleInputOrderByStartDateDesc(String userId, String value1); + @Query("{ $and: [ { 'executedByUserId': ?0 }, { 'scenarioExecutionInput.inputs.selected_project': ?1 } ] }") + List getFromProject(String userId, String value1, Sort sort); diff --git a/src/main/java/com/olympus/hermione/services/ScenarioExecutionService.java b/src/main/java/com/olympus/hermione/services/ScenarioExecutionService.java index 58e4942..daa142a 100644 --- a/src/main/java/com/olympus/hermione/services/ScenarioExecutionService.java +++ b/src/main/java/com/olympus/hermione/services/ScenarioExecutionService.java @@ -19,6 +19,7 @@ import org.springframework.ai.openai.api.OpenAiApi; import org.springframework.ai.vectorstore.VectorStore; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.client.discovery.DiscoveryClient; +import org.springframework.data.domain.Sort; import org.springframework.scheduling.annotation.Async; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; @@ -348,10 +349,10 @@ public class ScenarioExecutionService { User principal = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); if(principal.getSelectedApplication()!=null){ - lstScenarioExecution = scenarioExecutionRepository.findByExecutedByUserIdAndInputsOrderByStartDateDesc(principal.getId(), principal.getSelectedProject().getInternal_name(), principal.getSelectedApplication().getInternal_name()); + lstScenarioExecution = scenarioExecutionRepository.getFromProjectAndAPP(principal.getId(), principal.getSelectedProject().getInternal_name(), principal.getSelectedApplication().getInternal_name(), Sort.by(Sort.Direction.DESC, "startDate")); }else{ - lstScenarioExecution = scenarioExecutionRepository.findByExecutedByUserIdAndInputsOrderByStartDateDesc(principal.getId(), principal.getSelectedProject().getInternal_name(), null); + lstScenarioExecution = scenarioExecutionRepository.getFromProject(principal.getId(), principal.getSelectedProject().getInternal_name(), Sort.by(Sort.Direction.DESC, "startDate")); } return lstScenarioExecution; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c6c0c77..f443bbf 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -25,8 +25,11 @@ spring.ai.openai.api-key=sk-proj-j3TFJ0h348DIzMrYYfyUT3BlbkFJjk4HMc8A2ux2Asg8Y7H spring.ai.openai.chat.options.model=gpt-4o-mini spring.main.allow-circular-references=true -spring.ai.azure.openai.api-key=9fb33cc69d914d4c8225b974876510b5 -spring.ai.azure.openai.endpoint=https://ai-olympus.openai.azure.com/ +spring.ai.azure.openai.api-key=4eHwvw6h7vHxTmI2870cR3EpEBs5L9sXZabr9nz37y39TXtk0xY5JQQJ99AKAC5RqLJXJ3w3AAABACOGLdow +spring.ai.azure.openai.endpoint=https://ai-olympus-new.openai.azure.com/ + +#spring.ai.azure.openai.api-key=9fb33cc69d914d4c8225b974876510b5 +#spring.ai.azure.openai.endpoint=https://ai-olympus.openai.azure.com/ spring.ai.azure.openai.chat.options.deployment-name=gpt-4o-mini spring.ai.azure.openai.chat.options.temperature=0.7