From 005168965a62747dd07a98ad934df58a0c5b944e Mon Sep 17 00:00:00 2001 From: shohamroditimemphis Date: Wed, 29 Nov 2023 20:05:17 +0200 Subject: [PATCH] remove unnecessary fields --- models/functions.go | 57 +++++++------- server/memphis_handlers_functions_cloud.go | 92 ++++++++++------------ 2 files changed, 70 insertions(+), 79 deletions(-) diff --git a/models/functions.go b/models/functions.go index 165fd2e88..d8d7c511a 100644 --- a/models/functions.go +++ b/models/functions.go @@ -41,36 +41,33 @@ type Function struct { } type FunctionResult struct { - ID int `json:"id"` - FunctionName string `json:"function_name"` - Description string `json:"description"` - Tags []string `json:"tags"` - Runtime string `json:"runtime"` - Dependencies string `json:"dependencies"` - Inputs []map[string]string `json:"inputs"` - Memory int `json:"memory"` - Storage int `json:"storage"` - Handler string `json:"handler"` - TenantName string `json:"tenant_name"` - Scm string `json:"scm"` - Owner string `json:"owner"` - Repo string `json:"repo"` - Branch string `json:"branch"` - UpdatedAt time.Time `json:"installed_updated_at"` - Version int `json:"installed_version"` - InProgress bool `json:"installed_in_progress"` - ComputeEngine string `json:"compute_engine"` - Installed bool `json:"installed"` - IsValid bool `json:"is_valid"` - InvalidReason string `json:"invalid_reason"` - UpdatesAvailable bool `json:"updates_available"` - ByMemphis bool `json:"by_memphis"` - Language string `json:"language"` - Link *string `json:"link,omitempty"` - LastCommit *time.Time `json:"last_commit,omitempty"` - ClonedUpdatesAvailable bool `json:"cloned_updates_available"` - ClonedUpdatesIsValid bool `json:"cloned_updates_is_valid"` - ClonedUpdatesInvalidReason string `json:"cloned_updates_invalid_reason"` + ID int `json:"id"` + FunctionName string `json:"function_name"` + Description string `json:"description"` + Tags []string `json:"tags"` + Runtime string `json:"runtime"` + Dependencies string `json:"dependencies"` + Inputs []map[string]string `json:"inputs"` + Memory int `json:"memory"` + Storage int `json:"storage"` + Handler string `json:"handler"` + TenantName string `json:"tenant_name"` + Scm string `json:"scm"` + Owner string `json:"owner"` + Repo string `json:"repo"` + Branch string `json:"branch"` + UpdatedAt time.Time `json:"installed_updated_at"` + Version int `json:"installed_version"` + InProgress bool `json:"installed_in_progress"` + ComputeEngine string `json:"compute_engine"` + Installed bool `json:"installed"` + IsValid bool `json:"is_valid"` + InvalidReason string `json:"invalid_reason"` + UpdatesAvailable bool `json:"updates_available"` + ByMemphis bool `json:"by_memphis"` + Language string `json:"language"` + Link *string `json:"link,omitempty"` + LastCommit *time.Time `json:"last_commit,omitempty"` } type FunctionsRes struct { InstalledFunctions []FunctionResult `json:"installed_functions"` diff --git a/server/memphis_handlers_functions_cloud.go b/server/memphis_handlers_functions_cloud.go index b901c73b2..1fcde986e 100644 --- a/server/memphis_handlers_functions_cloud.go +++ b/server/memphis_handlers_functions_cloud.go @@ -73,30 +73,27 @@ func (fh FunctionsHandler) GetFunctions(tenantName string) (models.FunctionsRes, for _, function := range functions["other"] { if function.Owner == memphisDevFunctionsOwnerName && function.Repo == memphisDevFunctionsRepoName { otherFunctionResult := models.FunctionResult{ - FunctionName: function.FunctionName, - Description: function.Description, - Tags: function.Tags, - Runtime: function.Runtime, - Dependencies: function.Dependencies, - Inputs: function.Inputs, - Memory: function.Memory, - Storage: function.Storage, - Handler: function.Handler, - Scm: "github", - Repo: function.Repo, - Branch: function.Branch, - Owner: function.Owner, - Language: function.Language, - Version: -1, - IsValid: function.IsValid, - InvalidReason: function.InvalidReason, - InProgress: false, - UpdatesAvailable: false, - ByMemphis: function.ByMemphis, - TenantName: function.TenantName, - ClonedUpdatesAvailable: function.ClonedUpdatesAvailable, - ClonedUpdatesIsValid: function.ClonedUpdatesIsValid, - ClonedUpdatesInvalidReason: function.ClonedUpdatesInvalidReason, + FunctionName: function.FunctionName, + Description: function.Description, + Tags: function.Tags, + Runtime: function.Runtime, + Dependencies: function.Dependencies, + Inputs: function.Inputs, + Memory: function.Memory, + Storage: function.Storage, + Handler: function.Handler, + Scm: "github", + Repo: function.Repo, + Branch: function.Branch, + Owner: function.Owner, + Language: function.Language, + Version: -1, + IsValid: function.IsValid, + InvalidReason: function.InvalidReason, + InProgress: false, + UpdatesAvailable: false, + ByMemphis: function.ByMemphis, + TenantName: function.TenantName, } OtherFunctions = append(OtherFunctions, otherFunctionResult) lastModified = function.LastCommit @@ -261,31 +258,28 @@ func GetFunctionsDetails(functionsDetails map[string][]functionDetails) (map[str } functionDetails := models.FunctionResult{ - FunctionName: functionName, - Description: description, - Tags: tagsStrings, - Runtime: runtime, - Dependencies: dependencies, - Inputs: inputs, - Memory: memory, - Storage: storage, - Handler: handler, - Scm: "github", - Repo: repo, - Branch: branch, - Owner: owner, - LastCommit: lastCommit, - Link: link, - Language: language, - InProgress: false, - UpdatesAvailable: false, - ByMemphis: byMemphis, - TenantName: tenantName, - IsValid: isValid, - InvalidReason: invalidReason, - ClonedUpdatesAvailable: false, - ClonedUpdatesIsValid: isValid, - ClonedUpdatesInvalidReason: invalidReason, + FunctionName: functionName, + Description: description, + Tags: tagsStrings, + Runtime: runtime, + Dependencies: dependencies, + Inputs: inputs, + Memory: memory, + Storage: storage, + Handler: handler, + Scm: "github", + Repo: repo, + Branch: branch, + Owner: owner, + LastCommit: lastCommit, + Link: link, + Language: language, + InProgress: false, + UpdatesAvailable: false, + ByMemphis: byMemphis, + TenantName: tenantName, + IsValid: isValid, + InvalidReason: invalidReason, } functions[key] = append(functions[key], functionDetails)