Merge branch 'harduino-siemonster_workflows_order' into launch
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -4577,8 +4578,12 @@ func setExampleresult(ctx context.Context, result AppExecutionExample) error {
|
|||||||
|
|
||||||
// Hmm, so I guess this should use uuid :(
|
// Hmm, so I guess this should use uuid :(
|
||||||
// Consistency PLX
|
// Consistency PLX
|
||||||
func setWorkflow(ctx context.Context, workflow Workflow, id string) error {
|
func setWorkflow(ctx context.Context, workflow Workflow, id string, optionalEditedSecondsOffset ...int) error {
|
||||||
workflow.Edited = int64(time.Now().Unix())
|
workflow.Edited = int64(time.Now().Unix())
|
||||||
|
if len(optionalEditedSecondsOffset) > 0 {
|
||||||
|
workflow.Edited += int64(optionalEditedSecondsOffset[0])
|
||||||
|
}
|
||||||
|
|
||||||
key := datastore.NameKey("workflow", id, nil)
|
key := datastore.NameKey("workflow", id, nil)
|
||||||
|
|
||||||
// New struct, to not add body, author etc
|
// New struct, to not add body, author etc
|
||||||
@@ -6326,9 +6331,25 @@ func iterateOpenApiGithub(fs billy.Filesystem, dir []os.FileInfo, extra string,
|
|||||||
// Onlyname is used to
|
// Onlyname is used to
|
||||||
func iterateWorkflowGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra string, onlyname, userId, orgId string) error {
|
func iterateWorkflowGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra string, onlyname, userId, orgId string) error {
|
||||||
var err error
|
var err error
|
||||||
|
secondsOffset := 0
|
||||||
|
|
||||||
|
// sort file names
|
||||||
|
filenames := []string{}
|
||||||
for _, file := range dir {
|
for _, file := range dir {
|
||||||
if len(onlyname) > 0 && file.Name() != onlyname {
|
filename := file.Name()
|
||||||
|
filenames = append(filenames, filename)
|
||||||
|
}
|
||||||
|
sort.Strings(filenames)
|
||||||
|
|
||||||
|
// iterate through sorted filenames
|
||||||
|
for _, filename := range filenames {
|
||||||
|
secondsOffset -= 10
|
||||||
|
if len(onlyname) > 0 && filename != onlyname {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
file, err := fs.Stat(filename)
|
||||||
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6349,7 +6370,6 @@ func iterateWorkflowGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra
|
|||||||
}
|
}
|
||||||
case mode.IsRegular():
|
case mode.IsRegular():
|
||||||
// Check the file
|
// Check the file
|
||||||
filename := file.Name()
|
|
||||||
if strings.HasSuffix(filename, ".json") {
|
if strings.HasSuffix(filename, ".json") {
|
||||||
path := fmt.Sprintf("%s%s", extra, file.Name())
|
path := fmt.Sprintf("%s%s", extra, file.Name())
|
||||||
fileReader, err := fs.Open(path)
|
fileReader, err := fs.Open(path)
|
||||||
@@ -6402,8 +6422,9 @@ func iterateWorkflowGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
log.Printf("Import workflow from file: %s", filename)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
err = setWorkflow(ctx, workflow, workflow.ID)
|
err = setWorkflow(ctx, workflow, workflow.ID, secondsOffset)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed setting (download) workflow: %s", err)
|
log.Printf("Failed setting (download) workflow: %s", err)
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user