diff --git a/controllers/booking.go b/controllers/booking.go index 22a4700..fa812b3 100644 --- a/controllers/booking.go +++ b/controllers/booking.go @@ -1,6 +1,7 @@ package controllers import ( + "fmt" "net/http" "strconv" "time" @@ -20,39 +21,6 @@ type BookingController struct { var BookingExample booking.Booking -// @Title Search -// @Description search bookings by execution -// @Param id path string true "id execution" -// @Param is_draft query string false "draft wished" -// @Param offset query string false -// @Param limit query string false -// @Success 200 {workspace} models.workspace -// @router /search/execution/:id [get] -func (o *BookingController) ExecutionSearch() { - /* - * This is a sample of how to use the search function - * The search function is used to search for data in the database - * The search function takes in a filter and a data type - * The filter is a struct that contains the search parameters - * The data type is an enum that specifies the type of data to search for - * The search function returns a list of data that matches the filter - * The data is then returned as a json object - */ - // store and return Id or post with UUID - user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request) - id := o.Ctx.Input.Param(":id") - isDraft := o.Ctx.Input.Query("is_draft") - offset, _ := strconv.Atoi(o.Ctx.Input.Query("offset")) - limit, _ := strconv.Atoi(o.Ctx.Input.Query("limit")) - f := dbs.Filters{ - Or: map[string][]dbs.Filter{ // filter by name if no filters are provided - "execution_id": {{Operator: dbs.EQUAL.String(), Value: id}}, - }, - } - o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.BOOKING), user, peerID, groups, nil).Search(&f, "", isDraft == "true", int64(offset), int64(limit)) - o.ServeJSON() -} - // @Title Search // @Description search bookings // @Param start_date path string true "the word search you want to get" @@ -63,6 +31,7 @@ func (o *BookingController) ExecutionSearch() { // @Success 200 {workspace} models.workspace // @router /search/:start_date/:end_date [get] func (o *BookingController) Search() { + /* * This is a sample of how to use the search function * The search function is used to search for data in the database @@ -81,9 +50,10 @@ func (o *BookingController) Search() { isDraft := o.Ctx.Input.Query("is_draft") sd := primitive.NewDateTimeFromTime(start_date) ed := primitive.NewDateTimeFromTime(end_date) + fmt.Println("SEARCH START END", start_date, end_date) f := dbs.Filters{ And: map[string][]dbs.Filter{ - "execution_date": {{Operator: "gte", Value: sd}, {Operator: "lte", Value: ed}}, + "expected_start_date": {{Operator: "gte", Value: sd}, {Operator: "lte", Value: ed}}, }, } o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.BOOKING), user, peerID, groups, nil).Search(&f, "", isDraft == "true", int64(offset), int64(limit)) diff --git a/go.mod b/go.mod index bbf39f0..8a2db8b 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module oc-scheduler go 1.25.0 require ( - cloud.o-forge.io/core/oc-lib v0.0.0-20260407090927-6fe91eda875d + cloud.o-forge.io/core/oc-lib v0.0.0-20260408134044-284533ad1d7b github.com/beego/beego/v2 v2.3.8 github.com/google/uuid v1.6.0 github.com/robfig/cron v1.2.0 diff --git a/go.sum b/go.sum index 849593a..7c8e164 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,8 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20260407090336-526eaef33aa1 h1:uq6ZAHAqKVF9X cloud.o-forge.io/core/oc-lib v0.0.0-20260407090336-526eaef33aa1/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA= cloud.o-forge.io/core/oc-lib v0.0.0-20260407090927-6fe91eda875d h1:54Vl14gurwAkmZEaWZKUM5eDZfB7MF/fzWjibWLQljE= cloud.o-forge.io/core/oc-lib v0.0.0-20260407090927-6fe91eda875d/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA= +cloud.o-forge.io/core/oc-lib v0.0.0-20260408134044-284533ad1d7b h1:mOU+tc87/KEQgFmw1RcQ9E9Rbz8Q2jLOh5Cpu6po9Ww= +cloud.o-forge.io/core/oc-lib v0.0.0-20260408134044-284533ad1d7b/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0= github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= diff --git a/infrastructure/scheduler/scheduler.go b/infrastructure/scheduler/scheduler.go index 4b555f2..36ec71e 100644 --- a/infrastructure/scheduler/scheduler.go +++ b/infrastructure/scheduler/scheduler.go @@ -195,7 +195,7 @@ func (ws *WorkflowSchedule) GenerateExecutions(wf *workflow.Workflow, isPreempti obj := &workflow_execution.WorkflowExecution{ AbstractObject: utils.AbstractObject{ UUID: uuid.New().String(), - Name: wf.Name + "_execution_" + date.Start.String(), + Name: wf.Name + " execution " + date.Start.Format("2006-01-02 15:04"), }, Priority: 1, ExecutionsID: ws.UUID, diff --git a/oc-scheduler b/oc-scheduler deleted file mode 100755 index 34bce08..0000000 Binary files a/oc-scheduler and /dev/null differ diff --git a/routers/commentsRouter.go b/routers/commentsRouter.go index 5010c43..829ca3a 100644 --- a/routers/commentsRouter.go +++ b/routers/commentsRouter.go @@ -34,15 +34,6 @@ func init() { Filters: nil, Params: nil}) - beego.GlobalControllerRouter["oc-scheduler/controllers:BookingController"] = append(beego.GlobalControllerRouter["oc-scheduler/controllers:BookingController"], - beego.ControllerComments{ - Method: "ExecutionSearch", - Router: `/search/execution/:id`, - AllowHTTPMethods: []string{"get"}, - MethodParams: param.Make(), - Filters: nil, - Params: nil}) - beego.GlobalControllerRouter["oc-scheduler/controllers:ExecutionVerificationController"] = append(beego.GlobalControllerRouter["oc-scheduler/controllers:ExecutionVerificationController"], beego.ControllerComments{ Method: "GetAll", diff --git a/swagger/swagger.json b/swagger/swagger.json index e759b49..cf05e50 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -28,6 +28,18 @@ "name": "is_draft", "description": "draft wished", "type": "string" + }, + { + "in": "query", + "name": "offset", + "description": "false", + "type": "string" + }, + { + "in": "query", + "name": "limit", + "description": "false", + "type": "string" } ], "responses": { @@ -37,35 +49,6 @@ } } }, - "/booking/search/execution/{id}": { - "get": { - "tags": [ - "booking" - ], - "description": "search bookings by execution\n\u003cbr\u003e", - "operationId": "BookingController.Search", - "parameters": [ - { - "in": "path", - "name": "id", - "description": "id execution", - "required": true, - "type": "string" - }, - { - "in": "query", - "name": "is_draft", - "description": "draft wished", - "type": "string" - } - ], - "responses": { - "200": { - "description": "{workspace} models.workspace" - } - } - } - }, "/booking/search/{start_date}/{end_date}": { "get": { "tags": [ @@ -93,6 +76,18 @@ "name": "is_draft", "description": "draft wished", "type": "string" + }, + { + "in": "query", + "name": "offset", + "description": "false", + "type": "string" + }, + { + "in": "query", + "name": "limit", + "description": "false", + "type": "string" } ], "responses": { @@ -138,6 +133,18 @@ "name": "is_draft", "description": "draft wished", "type": "string" + }, + { + "in": "query", + "name": "offset", + "description": "false", + "type": "string" + }, + { + "in": "query", + "name": "limit", + "description": "false", + "type": "string" } ], "responses": { @@ -167,6 +174,18 @@ "name": "is_draft", "description": "draft wished", "type": "string" + }, + { + "in": "query", + "name": "offset", + "description": "false", + "type": "string" + }, + { + "in": "query", + "name": "limit", + "description": "false", + "type": "string" } ], "responses": { @@ -203,6 +222,18 @@ "name": "is_draft", "description": "draft wished", "type": "string" + }, + { + "in": "query", + "name": "offset", + "description": "false", + "type": "string" + }, + { + "in": "query", + "name": "limit", + "description": "false", + "type": "string" } ], "responses": { @@ -274,6 +305,18 @@ "description": "id execution", "required": true, "type": "string" + }, + { + "in": "query", + "name": "offset", + "description": "false", + "type": "string" + }, + { + "in": "query", + "name": "limit", + "description": "false", + "type": "string" } ], "responses": { @@ -296,6 +339,18 @@ "name": "is_draft", "description": "draft wished", "type": "string" + }, + { + "in": "query", + "name": "offset", + "description": "false", + "type": "string" + }, + { + "in": "query", + "name": "limit", + "description": "false", + "type": "string" } ], "responses": { diff --git a/swagger/swagger.yml b/swagger/swagger.yml index 1759f14..54c7369 100644 --- a/swagger/swagger.yml +++ b/swagger/swagger.yml @@ -44,6 +44,14 @@ paths: name: is_draft description: draft wished type: string + - in: query + name: offset + description: "false" + type: string + - in: query + name: limit + description: "false" + type: string responses: "200": description: '{booking} models.booking' @@ -87,26 +95,13 @@ paths: name: is_draft description: draft wished type: string - responses: - "200": - description: '{workspace} models.workspace' - /booking/search/execution/{id}: - get: - tags: - - booking - description: |- - search bookings by execution -
- operationId: BookingController.Search - parameters: - - in: path - name: id - description: id execution - required: true + - in: query + name: offset + description: "false" type: string - in: query - name: is_draft - description: draft wished + name: limit + description: "false" type: string responses: "200": @@ -124,6 +119,14 @@ paths: name: is_draft description: draft wished type: string + - in: query + name: offset + description: "false" + type: string + - in: query + name: limit + description: "false" + type: string responses: "200": description: '{workflow} models.workflow' @@ -162,6 +165,14 @@ paths: name: is_draft description: draft wished type: string + - in: query + name: offset + description: "false" + type: string + - in: query + name: limit + description: "false" + type: string responses: "200": description: '{compute} models.compute' @@ -188,6 +199,14 @@ paths: name: is_draft description: draft wished type: string + - in: query + name: offset + description: "false" + type: string + - in: query + name: limit + description: "false" + type: string responses: "200": description: '{workspace} models.workspace' @@ -223,6 +242,14 @@ paths: description: id execution required: true type: string + - in: query + name: offset + description: "false" + type: string + - in: query + name: limit + description: "false" + type: string responses: "200": description: '{workspace} models.workspace' @@ -239,6 +266,14 @@ paths: name: is_draft description: draft wished type: string + - in: query + name: offset + description: "false" + type: string + - in: query + name: limit + description: "false" + type: string responses: "200": description: '{booking} models.booking'