Rolled back reactJS as bugfix

This commit is contained in:
frikky
2021-01-21 08:59:58 +01:00
parent 2579d9a92d
commit ae4cbdadc8
3 changed files with 98 additions and 85 deletions
+2 -2
View File
@@ -6396,7 +6396,7 @@ func verifySwagger(resp http.ResponseWriter, request *http.Request) {
// FIXME: CHECK IF SAME NAME AS NORMAL APP // FIXME: CHECK IF SAME NAME AS NORMAL APP
// Can't overwrite existing normal app // Can't overwrite existing normal app
workflowApps, err := getAllWorkflowApps(ctx) workflowApps, err := getAllWorkflowApps(ctx, 100)
if err != nil { if err != nil {
log.Printf("Failed getting all workflow apps from database to verify: %s", err) log.Printf("Failed getting all workflow apps from database to verify: %s", err)
resp.WriteHeader(401) resp.WriteHeader(401)
@@ -7422,7 +7422,7 @@ func runInit(ctx context.Context) {
// Getting apps to see if we should initialize a test // Getting apps to see if we should initialize a test
log.Printf("Getting remote workflow apps") log.Printf("Getting remote workflow apps")
workflowapps, err := getAllWorkflowApps(ctx) workflowapps, err := getAllWorkflowApps(ctx, 100)
if err != nil { if err != nil {
log.Printf("Failed getting apps (runInit): %s", err) log.Printf("Failed getting apps (runInit): %s", err)
} else if err == nil && len(workflowapps) > 0 { } else if err == nil && len(workflowapps) > 0 {
+94 -81
View File
@@ -38,7 +38,7 @@ import (
// "google.golang.org/api/option" // "google.golang.org/api/option"
"github.com/patrickmn/go-cache" "github.com/patrickmn/go-cache"
//"google.golang.org/api/iterator" "google.golang.org/api/iterator"
) )
var localBase = "http://localhost:5001" var localBase = "http://localhost:5001"
@@ -1746,7 +1746,7 @@ func setNewWorkflow(resp http.ResponseWriter, request *http.Request) {
//log.Printf("APPENDING NEW APP FOR NEW WORKFLOW") //log.Printf("APPENDING NEW APP FOR NEW WORKFLOW")
// Adds the Testing app if it's a new workflow // Adds the Testing app if it's a new workflow
workflowapps, err := getAllWorkflowApps(ctx) workflowapps, err := getAllWorkflowApps(ctx, 100)
if err == nil { if err == nil {
// FIXME: Add real env // FIXME: Add real env
envName := "Shuffle" envName := "Shuffle"
@@ -2185,7 +2185,7 @@ func saveWorkflow(resp http.ResponseWriter, request *http.Request) {
log.Printf("[WORKFLOW INIT] NOT PREVIOUSLY SAVED - SET ACTION AUTH!") log.Printf("[WORKFLOW INIT] NOT PREVIOUSLY SAVED - SET ACTION AUTH!")
//AuthenticationId string `json:"authentication_id,omitempty" datastore:"authentication_id"` //AuthenticationId string `json:"authentication_id,omitempty" datastore:"authentication_id"`
workflowapps, apperr := getAllWorkflowApps(ctx) workflowapps, apperr := getAllWorkflowApps(ctx, 100)
allAuths, err := getAllWorkflowAppAuth(ctx, user.ActiveOrg.Id) allAuths, err := getAllWorkflowAppAuth(ctx, user.ActiveOrg.Id)
if err == nil && len(workflowapps) > 0 && apperr == nil { if err == nil && len(workflowapps) > 0 && apperr == nil {
log.Printf("Setting actions") log.Printf("Setting actions")
@@ -2310,7 +2310,7 @@ func saveWorkflow(resp http.ResponseWriter, request *http.Request) {
newActions = actionFixing newActions = actionFixing
} else { } else {
log.Printf("Err: %s - %s", err, apperr) log.Printf("Err: %s - %s", err, apperr)
//workflowapps, apperr := getAllWorkflowApps(ctx) //workflowapps, apperr := getAllWorkflowApps(ctx, 100)
//allAuths, err := getAllWorkflowAppAuth(ctx, user.ActiveOrg.Id) //allAuths, err := getAllWorkflowAppAuth(ctx, user.ActiveOrg.Id)
} }
@@ -2500,7 +2500,7 @@ func saveWorkflow(resp http.ResponseWriter, request *http.Request) {
//if item, err := memcache.Get(ctx, memcacheName); err == memcache.ErrCacheMiss { //if item, err := memcache.Get(ctx, memcacheName); err == memcache.ErrCacheMiss {
// // Not in cache // // Not in cache
// log.Printf("Apps not in cache.") // log.Printf("Apps not in cache.")
workflowApps, err = getAllWorkflowApps(ctx) workflowApps, err = getAllWorkflowApps(ctx, 100)
if err != nil { if err != nil {
log.Printf("Failed getting all workflow apps from database: %s", err) log.Printf("Failed getting all workflow apps from database: %s", err)
resp.WriteHeader(401) resp.WriteHeader(401)
@@ -5198,7 +5198,7 @@ func getWorkflowApps(resp http.ResponseWriter, request *http.Request) {
// return // return
//} //}
workflowapps, err := getAllWorkflowApps(ctx) workflowapps, err := getAllWorkflowApps(ctx, 100)
if err != nil { if err != nil {
log.Printf("Failed getting apps (getworkflowapps): %s", err) log.Printf("Failed getting apps (getworkflowapps): %s", err)
resp.WriteHeader(401) resp.WriteHeader(401)
@@ -5388,7 +5388,7 @@ func getSpecificApps(resp http.ResponseWriter, request *http.Request) {
// FIXME - continue the search here with github repos etc. // FIXME - continue the search here with github repos etc.
// Caching might be smart :D // Caching might be smart :D
ctx := context.Background() ctx := context.Background()
workflowapps, err := getAllWorkflowApps(ctx) workflowapps, err := getAllWorkflowApps(ctx, 100)
if err != nil { if err != nil {
log.Printf("Error: Failed getting workflowapps: %s", err) log.Printf("Error: Failed getting workflowapps: %s", err)
resp.WriteHeader(401) resp.WriteHeader(401)
@@ -5903,7 +5903,7 @@ func loadSpecificApps(resp http.ResponseWriter, request *http.Request) {
func iterateOpenApiGithub(fs billy.Filesystem, dir []os.FileInfo, extra string, onlyname string) error { func iterateOpenApiGithub(fs billy.Filesystem, dir []os.FileInfo, extra string, onlyname string) error {
ctx := context.Background() ctx := context.Background()
workflowapps, err := getAllWorkflowApps(ctx) workflowapps, err := getAllWorkflowApps(ctx, 100)
appCounter := 0 appCounter := 0
if err != nil { if err != nil {
log.Printf("Failed to get existing generated apps") log.Printf("Failed to get existing generated apps")
@@ -6275,7 +6275,7 @@ func iterateAppGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra strin
} }
if len(allapps) == 0 { if len(allapps) == 0 {
allapps, err = getAllWorkflowApps(ctx) allapps, err = getAllWorkflowApps(ctx, 100)
if err != nil { if err != nil {
log.Printf("Failed getting apps to verify: %s", err) log.Printf("Failed getting apps to verify: %s", err)
continue continue
@@ -6492,7 +6492,7 @@ func setNewWorkflowApp(resp http.ResponseWriter, request *http.Request) {
} }
ctx := context.Background() ctx := context.Background()
allapps, err := getAllWorkflowApps(ctx) allapps, err := getAllWorkflowApps(ctx, 100)
if err != nil { if err != nil {
log.Printf("Failed getting apps to verify: %s", err) log.Printf("Failed getting apps to verify: %s", err)
resp.WriteHeader(401) resp.WriteHeader(401)
@@ -6657,87 +6657,100 @@ func getAllSchedules(ctx context.Context, orgId string) ([]ScheduleOld, error) {
} }
//FIXME: Add cursor //FIXME: Add cursor
func getAllWorkflowApps(ctx context.Context) ([]WorkflowApp, error) { func getAllWorkflowApps(ctx context.Context, maxLen int) ([]WorkflowApp, error) {
var apps []WorkflowApp var apps []WorkflowApp
//query := datastore.NewQuery("workflowapp").Order("-edited").Limit(20) query := datastore.NewQuery("workflowapp").Order("-edited").Limit(20)
query := datastore.NewQuery("workflowapp").Order("-edited").Limit(40) //query := datastore.NewQuery("workflowapp").Order("-edited").Limit(40)
//cacheKey := fmt.Sprintf("workflowapps-sorted") cacheKey := fmt.Sprintf("workflowapps-sorted")
//if value, found := requestCache.Get(cacheKey); found { if value, found := requestCache.Get(cacheKey); found {
// parsedValue := value.([]WorkflowApp) parsedValue := value.(*[]WorkflowApp)
// log.Printf("[INFO] Returning %d apps", len(parsedValue)) log.Printf("[INFO] Returning %d apps from cache", len(*parsedValue))
// return parsedValue, nil return *parsedValue, nil
//} }
//maxLen := 100 cursorStr := ""
//cursorStr := ""
//var app WorkflowApp
//for {
// it := dbclient.Run(ctx, query)
// _, err := it.Next(&app)
// for err == nil {
// found := false
// for _, innerapp := range apps {
// if innerapp.Name == app.Name {
// found = true
// break
// } // NOT BEING UPDATED
// } // FIXME: Update the app with the correct actions. HOW DOES THIS WORK??
// Seems like only actions are wrong. Could get the app individually.
// if found == false { // Guessing it's a memory issue.
// apps = append(apps, app) //Actions []WorkflowAppAction `json:"actions" yaml:"actions" required:true datastore:"actions,noindex"`
// } //errors.New(nil)
// _, err = it.Next(&app) var err error
// } for {
it := dbclient.Run(ctx, query)
// if err != iterator.Done { //_, err = it.Next(&app)
// log.Fatalf("Failed fetching results: %v", err) for {
// } var app WorkflowApp
_, err := it.Next(&app)
// // Get the cursor for the next page of results.
// nextCursor, err := it.Cursor()
// if err != nil {
// log.Printf("Cursorerror: %s", err)
// break
// } else {
// //log.Printf("NEXTCURSOR: %s", nextCursor)
// nextStr := fmt.Sprintf("%s", nextCursor)
// if cursorStr == nextStr {
// break
// }
// cursorStr = nextStr
// query = query.Start(nextCursor)
// //cursorStr = nextCursor
// //break
// }
// if len(apps) > maxLen {
// break
// }
//}
//if len(apps) > 20 {
// requestCache.Set(cacheKey, apps, cache.DefaultExpiration)
//}
var allworkflowapps []WorkflowApp
_, err := dbclient.GetAll(ctx, query, &allworkflowapps)
if err != nil {
if strings.Contains(fmt.Sprintf("%s", err), "ResourceExhausted") {
//datastore.NewQuery("workflowapp").Limit(30).Order("-edited")
query = datastore.NewQuery("workflowapp").Order("-edited").Limit(25)
//q := q.Limit(25)
_, err := dbclient.GetAll(ctx, query, &allworkflowapps)
if err != nil { if err != nil {
return []WorkflowApp{}, err break
} }
found := false
//log.Printf("ACTIONS: %d - %s", len(app.Actions), app.Name)
for _, innerapp := range apps {
if innerapp.Name == app.Name {
found = true
break
}
}
if !found {
apps = append(apps, app)
}
}
if err != iterator.Done {
//log.Printf("[INFO] Failed fetching results: %v", err)
//break
}
// Get the cursor for the next page of results.
nextCursor, err := it.Cursor()
if err != nil {
log.Printf("Cursorerror: %s", err)
break
} else { } else {
return []WorkflowApp{}, err //log.Printf("NEXTCURSOR: %s", nextCursor)
nextStr := fmt.Sprintf("%s", nextCursor)
if cursorStr == nextStr {
break
}
cursorStr = nextStr
query = query.Start(nextCursor)
//cursorStr = nextCursor
//break
}
if len(apps) > maxLen {
break
} }
} }
if len(apps) > 20 {
log.Printf("[INFO] Setting %d apps in cache", len(apps))
requestCache.Set(cacheKey, &apps, cache.DefaultExpiration)
}
//var allworkflowapps []WorkflowApp
//_, err := dbclient.GetAll(ctx, query, &allworkflowapps)
//if err != nil {
// if strings.Contains(fmt.Sprintf("%s", err), "ResourceExhausted") {
// //datastore.NewQuery("workflowapp").Limit(30).Order("-edited")
// query = datastore.NewQuery("workflowapp").Order("-edited").Limit(25)
// //q := q.Limit(25)
// _, err := dbclient.GetAll(ctx, query, &allworkflowapps)
// if err != nil {
// return []WorkflowApp{}, err
// }
// } else {
// return []WorkflowApp{}, err
// }
//}
return apps, nil return apps, nil
} }
+2 -2
View File
@@ -32,7 +32,7 @@
"md5-file": "^4.0.0", "md5-file": "^4.0.0",
"mdbreact": "^4.21.1", "mdbreact": "^4.21.1",
"moment": "~2.20.1", "moment": "~2.20.1",
"react": "^17.0.1", "react": "^16.14.0",
"react-alert": "^5.5.0", "react-alert": "^5.5.0",
"react-alert-template-basic": "^1.0.0", "react-alert-template-basic": "^1.0.0",
"react-beforeunload": "^2.2.1", "react-beforeunload": "^2.2.1",
@@ -40,7 +40,7 @@
"react-cookie": "^4.0.1", "react-cookie": "^4.0.1",
"react-cytoscapejs": "^1.2.0", "react-cytoscapejs": "^1.2.0",
"react-device-detect": "^1.9.10", "react-device-detect": "^1.9.10",
"react-dom": "^17.0.1", "react-dom": "^16.14.0",
"react-draggable": "^3.3.2", "react-draggable": "^3.3.2",
"react-dropzone": "^10.1.10", "react-dropzone": "^10.1.10",
"react-ga": "^2.7.0", "react-ga": "^2.7.0",