Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shohamroditimemphis committed Oct 27, 2023
1 parent ff1c0d5 commit 425e7ed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions models/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ type FunctionsResult struct {
}

type FunctionsRes struct {
InstallFunctions []FunctionsResult `json:"install_functions"`
OtherFunctions []FunctionsResult `json:"other_functions"`
ScmIntegrated bool `json:"scm_integrated"`
ConnectedRepos []map[string]interface{} `json:"connected_repos"`
InstalledFunctions []FunctionsResult `json:"installed_functions"`
OtherFunctions []FunctionsResult `json:"other_functions"`
ScmIntegrated bool `json:"scm_integrated"`
ConnectedRepos []map[string]interface{} `json:"connected_repos"`
}

type GetFunctionDetails struct {
Expand Down
18 changes: 7 additions & 11 deletions server/memphis_handlers_functions_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (fh FunctionsHandler) GetAllFunctions(c *gin.Context) {
}
}

c.IndentedJSON(200, gin.H{"scm_integrated": functionsResult.ScmIntegrated, "other": functionsResult.OtherFunctions, "installed": functionsResult.InstallFunctions, "connected_repos": functionsResult.ConnectedRepos})
c.IndentedJSON(200, gin.H{"scm_integrated": functionsResult.ScmIntegrated, "other": functionsResult.OtherFunctions, "installed": functionsResult.InstalledFunctions, "connected_repos": functionsResult.ConnectedRepos})
}

func (fh FunctionsHandler) GetFunctions(tenantName string) (models.FunctionsRes, error) {
Expand All @@ -62,12 +62,8 @@ func (fh FunctionsHandler) GetFunctions(tenantName string) (models.FunctionsRes,
if err != nil {
return models.FunctionsRes{}, err
}
if len(functions) > 10 {
functions["install"] = functions["install"][:10]
functions["other"] = functions["other"][:10]
}

installedFunctions := functions["install"]
installedFunctions := functions["installed"]
OtherFunctions := functions["other"]
if len(installedFunctions) == 0 {
installedFunctions = []models.FunctionsResult{}
Expand All @@ -81,10 +77,10 @@ func (fh FunctionsHandler) GetFunctions(tenantName string) (models.FunctionsRes,
memphisDevFucntions = append(memphisDevFucntions, memphisFunctions)

allFunctions := models.FunctionsRes{
InstallFunctions: installedFunctions,
OtherFunctions: OtherFunctions,
ScmIntegrated: scmIntegrated,
ConnectedRepos: memphisDevFucntions,
InstalledFunctions: installedFunctions,
OtherFunctions: OtherFunctions,
ScmIntegrated: scmIntegrated,
ConnectedRepos: memphisDevFucntions,
}

return allFunctions, nil
Expand Down Expand Up @@ -275,7 +271,7 @@ func GetFunctionsDetails(functionsDetails map[string][]functionDetails) (map[str
}

byMemphis := false
if repo == memphisDevFunctionsRepoName {
if repo == memphisDevFunctionsRepoName && owner == memphisDevFunctionsOwnerName {
byMemphis = true
}

Expand Down
6 changes: 5 additions & 1 deletion server/source_code_management_github_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ func GetGithubContentFromConnectedRepo(connectedRepo map[string]interface{}, fun
return functionsDetails, err
}

for _, directoryContent := range repoContent {
for k, directoryContent := range repoContent {
// In order to restrict the api calls per repo
if k == 10 {
break
}
if directoryContent.GetType() == "dir" {
_, filesContent, _, err := client.Repositories.GetContents(context.Background(), owner, repo, *directoryContent.Path, &github.RepositoryContentGetOptions{
Ref: branch})
Expand Down

0 comments on commit 425e7ed

Please sign in to comment.