From 4d595134b54f5f4bbe8a31fc4d17263c9502280f Mon Sep 17 00:00:00 2001 From: Pascal Delange Date: Fri, 3 Jan 2025 17:20:37 +0100 Subject: [PATCH] drop unused code --- api/handle_ast_expression.go | 25 ------------------------- api/handle_editor.go | 17 ----------------- api/routes.go | 3 --- dto/func_attributes_dto.go | 15 --------------- models/ast/ast_function.go | 23 ----------------------- usecases/ast_expression_usecase.go | 18 ------------------ 6 files changed, 101 deletions(-) delete mode 100644 api/handle_ast_expression.go delete mode 100644 dto/func_attributes_dto.go diff --git a/api/handle_ast_expression.go b/api/handle_ast_expression.go deleted file mode 100644 index 215de1644..000000000 --- a/api/handle_ast_expression.go +++ /dev/null @@ -1,25 +0,0 @@ -package api - -import ( - "net/http" - - "github.com/gin-gonic/gin" - - "github.com/checkmarble/marble-backend/dto" - "github.com/checkmarble/marble-backend/models/ast" -) - -func handleAvailableFunctions(c *gin.Context) { - functions := make(map[string]dto.FuncAttributesDto) - - for f, attributes := range ast.FuncAttributesMap { - if f == ast.FUNC_CONSTANT || f == ast.FUNC_UNDEFINED { - continue - } - functions[attributes.AstName] = dto.AdaptFuncAttributesDto(attributes) - } - - c.JSON(http.StatusOK, gin.H{ - "functions": functions, - }) -} diff --git a/api/handle_editor.go b/api/handle_editor.go index 0769e70fa..e923df5bd 100644 --- a/api/handle_editor.go +++ b/api/handle_editor.go @@ -37,20 +37,3 @@ func handleGetEditorIdentifiers(uc usecases.Usecases) func(c *gin.Context) { }) } } - -func handleGetEditorOperators(uc usecases.Usecases) func(c *gin.Context) { - return func(c *gin.Context) { - ctx := c.Request.Context() - usecase := usecasesWithCreds(ctx, uc).AstExpressionUsecase() - result := usecase.EditorOperators() - - var functions []dto.FuncAttributesDto - - for _, attributes := range result.OperatorAccessors { - functions = append(functions, dto.AdaptFuncAttributesDto(attributes)) - } - c.JSON(http.StatusOK, gin.H{ - "operators_accessors": functions, - }) - } -} diff --git a/api/routes.go b/api/routes.go index 4e4946581..cec22514a 100644 --- a/api/routes.go +++ b/api/routes.go @@ -32,8 +32,6 @@ func addRoutes(r *gin.Engine, conf Configuration, uc usecases.Usecases, auth Aut router.GET("/credentials", tom, handleGetCredentials()) - router.GET("/ast-expression/available-functions", tom, handleAvailableFunctions) - router.GET("/decisions", timeoutMiddleware(conf.DecisionTimeout), handleListDecisions(uc, conf.MarbleAppHost)) @@ -114,7 +112,6 @@ func addRoutes(r *gin.Engine, conf Configuration, uc usecases.Usecases, auth Aut router.DELETE("/custom-lists/:list_id/values/:value_id", tom, handleDeleteCustomListValue(uc)) router.GET("/editor/:scenario_id/identifiers", tom, handleGetEditorIdentifiers(uc)) - router.GET("/editor/:scenario_id/operators", tom, handleGetEditorOperators(uc)) router.GET("/users", tom, handleListUsers(uc)) router.POST("/users", tom, handlePostUser(uc)) diff --git a/dto/func_attributes_dto.go b/dto/func_attributes_dto.go deleted file mode 100644 index 9357c799f..000000000 --- a/dto/func_attributes_dto.go +++ /dev/null @@ -1,15 +0,0 @@ -package dto - -import ( - "github.com/checkmarble/marble-backend/models/ast" -) - -type FuncAttributesDto struct { - Name string `json:"name"` -} - -func AdaptFuncAttributesDto(attributes ast.FuncAttributes) FuncAttributesDto { - return FuncAttributesDto{ - Name: attributes.AstName, - } -} diff --git a/models/ast/ast_function.go b/models/ast/ast_function.go index b9d326b3d..dddbae6ed 100644 --- a/models/ast/ast_function.go +++ b/models/ast/ast_function.go @@ -8,29 +8,6 @@ import ( type Function int -var FuncOperators = []Function{ - FUNC_ADD, - FUNC_SUBTRACT, - FUNC_MULTIPLY, - FUNC_DIVIDE, - FUNC_GREATER, - FUNC_GREATER_OR_EQUAL, - FUNC_LESS, - FUNC_LESS_OR_EQUAL, - FUNC_EQUAL, - FUNC_NOT_EQUAL, - FUNC_IS_IN_LIST, - FUNC_IS_NOT_IN_LIST, - FUNC_STRING_CONTAINS, - FUNC_STRING_NOT_CONTAIN, - FUNC_CONTAINS_ANY, - FUNC_CONTAINS_NONE, - FUNC_STRING_STARTS_WITH, - FUNC_STRING_ENDS_WITH, - FUNC_IS_EMPTY, - FUNC_IS_NOT_EMPTY, -} - const ( FUNC_CONSTANT Function = iota FUNC_ADD diff --git a/usecases/ast_expression_usecase.go b/usecases/ast_expression_usecase.go index 5e3739a17..63759691a 100644 --- a/usecases/ast_expression_usecase.go +++ b/usecases/ast_expression_usecase.go @@ -28,10 +28,6 @@ type EditorIdentifiers struct { DatabaseAccessors []ast.Node `json:"database_accessors"` } -type EditorOperators struct { - OperatorAccessors []ast.FuncAttributes `json:"operator_accessors"` -} - func (usecase *AstExpressionUsecase) getLinkedDatabaseIdentifiers(scenario models.Scenario, dataModel models.DataModel) ([]ast.Node, error) { dataAccessors := []ast.Node{} var recursiveDatabaseAccessor func(path []string, links map[string]models.LinkToSingle) error @@ -135,17 +131,3 @@ func (usecase *AstExpressionUsecase) EditorIdentifiers(ctx context.Context, scen DatabaseAccessors: databaseAccessors, }, nil } - -func (usecase *AstExpressionUsecase) EditorOperators() EditorOperators { - if err := usecase.EnforceSecurity.Permission(models.SCENARIO_READ); err != nil { - return EditorOperators{} - } - - var operatorAccessors []ast.FuncAttributes - for _, functionType := range ast.FuncOperators { - operatorAccessors = append(operatorAccessors, ast.FuncAttributesMap[functionType]) - } - return EditorOperators{ - OperatorAccessors: operatorAccessors, - } -}