Naming clear

This commit is contained in:
mr
2026-04-09 07:50:58 +02:00
parent 1d63d31442
commit da4d4bd546
8 changed files with 145 additions and 92 deletions

View File

@@ -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))

2
go.mod
View File

@@ -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

2
go.sum
View File

@@ -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=

View File

@@ -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,

Binary file not shown.

View File

@@ -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",

View File

@@ -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": {

View File

@@ -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
<br>
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'