Skip to content

Commit

Permalink
Fixed backend
Browse files Browse the repository at this point in the history
  • Loading branch information
frikky committed May 27, 2024
1 parent 4de3df8 commit de0e7d6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
29 changes: 28 additions & 1 deletion db-connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -7521,7 +7521,7 @@ func SetWorkflow(ctx context.Context, workflow Workflow, id string, optionalEdit
// New struct, to not add body, author etc
data, err := json.Marshal(workflow)
if err != nil {
log.Printf("[WARNING] Failed marshalling in getworkflow: %s", err)
log.Printf("[WARNING] Failed marshalling in set workflow: %s", err)
return nil
}

Expand Down Expand Up @@ -12803,3 +12803,30 @@ func DeleteDbIndex(ctx context.Context, index string) error {

return nil
}

func SetTraining(ctx context.Context, training Training) error {
if project.DbType == "opensearch" {
return errors.New("Not implemented")
}

if training.ID == "" {
training.ID = uuid.NewV4().String()
}

if training.SignupTime == 0 {
training.SignupTime = time.Now().Unix()
}

// Overwriting to be sure these are matching
// No real point in having id + workflow.ID anymore
nameKey := "training"

log.Printf("[INFO] Setting training with %d attendants", training.NumberOfAttendees)
key := datastore.NameKey(nameKey, training.ID, nil)
if _, err := project.Dbclient.Put(ctx, key, &training); err != nil {
log.Printf("[ERROR] Failed adding training with ID %s: %s", training.ID, err)
return err
}

return nil
}
12 changes: 12 additions & 0 deletions structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3865,3 +3865,15 @@ type SSOResponse struct {
Reason string `json:"reason"`
URL string `json:"url"`
}

type Training struct {
Name string `json:"Name"`
Email string `json:"Email"`
NumberOfAttendees int `json:"numberOfAttendees"`
Message string `json:"Message"`
Time string `json:"Time"`
Country string `json:"Country"`

ID string `json:"id"`
SignupTime int64 `json:"signupTime"`
}

0 comments on commit de0e7d6

Please sign in to comment.