Skip to content

Commit

Permalink
Started adding suborg workflow distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
frikky committed May 9, 2024
1 parent 462ff16 commit 1938def
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app_upload/stitcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,8 @@ func main() {
bucketName = os.Args[5]
}

appname := "shuffle-tools"
appversion := "1.2.0"
appname := "email"
appversion := "1.3.0"
err := deployConfigToBackend(appfolder, appname, appversion)
if err != nil {
log.Printf("[WARNING] Failed uploading config: %s", err)
Expand Down
61 changes: 60 additions & 1 deletion db-connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3215,6 +3215,65 @@ func GetAllWorkflowsByQuery(ctx context.Context, user User) ([]Workflow, error)
query = query.Start(nextCursor)
}
}

/*
if len(user.ActiveOrg.Id) > 0 {
log.Printf("[INFO] Appending suborg distribution workflows for organization %s (%s)", user.ActiveOrg.Name, user.ActiveOrg.Id)
query = datastore.NewQuery(nameKey)
query.FilterField("suborg_distribution", "in", []string{user.ActiveOrg.Id}).Limit(25)
cursorStr = ""
for {
it := project.Dbclient.Run(ctx, query)
for {
innerWorkflow := Workflow{}
_, err := it.Next(&innerWorkflow)
log.Printf("[DEBUG] Got suborg workflow %s (%s)", innerWorkflow.Name, innerWorkflow.ID)
if err != nil {
if strings.Contains(fmt.Sprintf("%s", err), "cannot load field") {
log.Printf("[ERROR] Error in workflow loading. Migrating workflow to new workflow handler (1): %s", err)
continue
}
break
}
found := false
for _, loopedWorkflow := range workflows {
if loopedWorkflow.ID == innerWorkflow.ID {
found = true
break
}
}
if !found {
workflows = append(workflows, innerWorkflow)
}
}
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 {
nextStr := fmt.Sprintf("%s", nextCursor)
if cursorStr == nextStr {
break
}
cursorStr = nextStr
query = query.Start(nextCursor)
}
}
}
*/
}

fixedWorkflows := []Workflow{}
Expand Down Expand Up @@ -5583,7 +5642,7 @@ func GetPrioritizedApps(ctx context.Context, user User) ([]WorkflowApp, error) {
_, err := it.Next(&innerApp)
if err != nil {
if strings.Contains(fmt.Sprintf("%s", err), "cannot load field") {
log.Printf("[ERROR] Error in reference_org load: %s.", err)
log.Printf("[ERROR] Error in reference_org app load of %s (%s): %s.", innerApp.Name, innerApp.ID, err)
continue
}

Expand Down
6 changes: 4 additions & 2 deletions files.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,10 @@ func HandleGetFileNamespace(resp http.ResponseWriter, request *http.Request) {
//resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed loading file from Github repo %s/%s"}`, owner, repo)))
//return
} else {
log.Printf("[DEBUG] Found %d files in category %s for filename '%s'", len(foundFiles), namespace, filename[0])
log.Printf("[DEBUG] Found %d file(s) in category %s for filename '%s'", len(foundFiles), namespace, filename[0])
for _, item := range foundFiles {
//log.printf("[DEBUG] %#v: %s", *item.Name, item.Status)

fileContent, _, _, err := client.Repositories.GetContents(ctx, owner, repo, *item.Path, nil)
if err != nil {
log.Printf("[ERROR] Failed getting file %s: %s", *item.Path, err)
Expand All @@ -646,7 +648,7 @@ func HandleGetFileNamespace(resp http.ResponseWriter, request *http.Request) {
//log.Printf("[DEBUG] Decoded file %s with content:\n%s", *item.Path, string(decoded))

timeNow := time.Now().Unix()
fileId := uuid.NewV4().String()
fileId := "file_"+uuid.NewV4().String()

folderPath := fmt.Sprintf("%s/%s/%s", basepath, user.ActiveOrg.Id, "global")
downloadPath := fmt.Sprintf("%s/%s", folderPath, fileId)
Expand Down
1 change: 1 addition & 0 deletions structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,7 @@ type Workflow struct {
UpdatedBy string `json:"updated_by" datastore:"updated_by"`

Validated bool `json:"validated" datastore:"validated"`
SuborgDistribution []string `json:"suborg_distribution" datastore:"suborg_distribution"`
}

type Category struct {
Expand Down

0 comments on commit 1938def

Please sign in to comment.