Skip to content

Commit

Permalink
Minor improvements to search aql
Browse files Browse the repository at this point in the history
  • Loading branch information
RobiNino committed Dec 25, 2018
1 parent aff0239 commit 5fadb4f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion artifactory/services/utils/aqlquerybuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func getQueryReturnFields(specFile *ArtifactoryCommonParams, requiredArtifactPro
return appendMissingFields(specFile.SortBy, returnFields)
}
if requiredArtifactProps != NONE {
// If any prop is needed we just adding all the properties to the result, in order to prevent the second props query.
// If any prop is needed we just add all the properties to the result.
return append(returnFields, "property")
}
return returnFields
Expand Down
11 changes: 2 additions & 9 deletions artifactory/services/utils/artifactoryutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func getBuildNumberFromArtifactory(buildName, buildNumber string, flags CommonCo
func createBodyForLatestBuildRequest(buildName, buildNumber string) (body []byte, err error) {
buildJsonArray := []build{{buildName, buildNumber}}
body, err = json.Marshal(buildJsonArray)
errorutils.CheckError(err)
err = errorutils.CheckError(err)
return
}

Expand Down Expand Up @@ -254,16 +254,9 @@ func filterAqlSearchResultsByBuild(specFile *ArtifactoryCommonParams, itemsToFil
// Run AQL to retrieve all artifacts associated with a specific build.
// Return a map of the artifacts SHA1.
func fetchBuildArtifactsSha1(buildName, buildNumber string, flags CommonConf) (map[string]bool, error) {
var aqlSearchErr error
var buildAqlResponse []byte

buildQuery := createAqlQueryForBuild(buildName, buildNumber, buildIncludeQueryPart([]string{"name", "repo", "path", "actual_sha1"}))

buildAqlResponse, aqlSearchErr = ExecAql(buildQuery, flags)
if aqlSearchErr != nil {
return nil, aqlSearchErr
}
parsedBuildAqlResponse, err := parseAqlSearchResponse(buildAqlResponse)
parsedBuildAqlResponse, err := aqlSearch(buildQuery, flags)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions artifactory/services/utils/searchutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func SearchBySpecWithAql(specFile *ArtifactoryCommonParams, flags CommonConf, re

// Filter results by build.
if specFile.Build != "" && len(results) > 0 {
// If requiredArtifactProps is set to All and 'includePropertiesInAqlForSpec' for specFile returned true, results contains properties for artifacts.
resultsArtifactsIncludeProperties := requiredArtifactProps == ALL && includePropertiesInAqlForSpec(specFile)
// If requiredArtifactProps is not NONE and 'includePropertiesInAqlForSpec' for specFile returned true, results contains properties for artifacts.
resultsArtifactsIncludeProperties := requiredArtifactProps != NONE && includePropertiesInAqlForSpec(specFile)
results, err = filterAqlSearchResultsByBuild(specFile, results, flags, resultsArtifactsIncludeProperties)
if err != nil {
return nil, err
Expand Down

0 comments on commit 5fadb4f

Please sign in to comment.