aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/api/packages/composer/composer.go4
-rw-r--r--routers/api/packages/npm/npm.go7
-rw-r--r--routers/api/packages/nuget/nuget.go6
-rw-r--r--routers/api/packages/rubygems/rubygems.go15
-rw-r--r--routers/api/v1/packages/package.go4
-rw-r--r--routers/web/admin/packages.go6
-rw-r--r--routers/web/repo/packages.go8
-rw-r--r--routers/web/user/package.go15
8 files changed, 41 insertions, 24 deletions
diff --git a/routers/api/packages/composer/composer.go b/routers/api/packages/composer/composer.go
index 22a452325e..23de28c7f9 100644
--- a/routers/api/packages/composer/composer.go
+++ b/routers/api/packages/composer/composer.go
@@ -63,8 +63,8 @@ func SearchPackages(ctx *context.Context) {
opts := &packages_model.PackageSearchOptions{
OwnerID: ctx.Package.Owner.ID,
- Type: string(packages_model.TypeComposer),
- QueryName: ctx.FormTrim("q"),
+ Type: packages_model.TypeComposer,
+ Name: packages_model.SearchValue{Value: ctx.FormTrim("q")},
Paginator: &paginator,
}
if ctx.FormTrim("type") != "" {
diff --git a/routers/api/packages/npm/npm.go b/routers/api/packages/npm/npm.go
index 50151ee5ea..d127134d44 100644
--- a/routers/api/packages/npm/npm.go
+++ b/routers/api/packages/npm/npm.go
@@ -256,7 +256,12 @@ func setPackageTag(tag string, pv *packages_model.PackageVersion, deleteOnly boo
}
defer committer.Close()
- pvs, err := packages_model.FindVersionsByPropertyNameAndValue(ctx, pv.PackageID, npm_module.TagProperty, tag)
+ pvs, _, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
+ PackageID: pv.PackageID,
+ Properties: map[string]string{
+ npm_module.TagProperty: tag,
+ },
+ })
if err != nil {
return err
}
diff --git a/routers/api/packages/nuget/nuget.go b/routers/api/packages/nuget/nuget.go
index 3af7155fae..013c0c1e33 100644
--- a/routers/api/packages/nuget/nuget.go
+++ b/routers/api/packages/nuget/nuget.go
@@ -39,9 +39,9 @@ func ServiceIndex(ctx *context.Context) {
// SearchService https://docs.microsoft.com/en-us/nuget/api/search-query-service-resource#search-for-packages
func SearchService(ctx *context.Context) {
pvs, count, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
- OwnerID: ctx.Package.Owner.ID,
- Type: string(packages_model.TypeNuGet),
- QueryName: ctx.FormTrim("q"),
+ OwnerID: ctx.Package.Owner.ID,
+ Type: packages_model.TypeNuGet,
+ Name: packages_model.SearchValue{Value: ctx.FormTrim("q")},
Paginator: db.NewAbsoluteListOptions(
ctx.FormInt("skip"),
ctx.FormInt("take"),
diff --git a/routers/api/packages/rubygems/rubygems.go b/routers/api/packages/rubygems/rubygems.go
index a5a9b779ab..6fdd03e8ea 100644
--- a/routers/api/packages/rubygems/rubygems.go
+++ b/routers/api/packages/rubygems/rubygems.go
@@ -41,7 +41,7 @@ func EnumeratePackages(ctx *context.Context) {
func EnumeratePackagesLatest(ctx *context.Context) {
pvs, _, err := packages_model.SearchLatestVersions(ctx, &packages_model.PackageSearchOptions{
OwnerID: ctx.Package.Owner.ID,
- Type: string(packages_model.TypeRubyGems),
+ Type: packages_model.TypeRubyGems,
})
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
@@ -96,7 +96,7 @@ func ServePackageSpecification(ctx *context.Context) {
return
}
- pvs, err := packages_model.GetVersionsByFilename(ctx, ctx.Package.Owner.ID, packages_model.TypeRubyGems, filename[:len(filename)-10]+"gem")
+ pvs, err := getVersionsByFilename(ctx, filename[:len(filename)-10]+"gem")
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
@@ -158,7 +158,7 @@ func ServePackageSpecification(ctx *context.Context) {
func DownloadPackageFile(ctx *context.Context) {
filename := ctx.Params("filename")
- pvs, err := packages_model.GetVersionsByFilename(ctx, ctx.Package.Owner.ID, packages_model.TypeRubyGems, filename)
+ pvs, err := getVersionsByFilename(ctx, filename)
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
@@ -283,3 +283,12 @@ func DeletePackage(ctx *context.Context) {
apiError(ctx, http.StatusInternalServerError, err)
}
}
+
+func getVersionsByFilename(ctx *context.Context, filename string) ([]*packages_model.PackageVersion, error) {
+ pvs, _, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
+ OwnerID: ctx.Package.Owner.ID,
+ Type: packages_model.TypeRubyGems,
+ HasFileWithName: filename,
+ })
+ return pvs, err
+}
diff --git a/routers/api/v1/packages/package.go b/routers/api/v1/packages/package.go
index 8952241222..b445e8e2f8 100644
--- a/routers/api/v1/packages/package.go
+++ b/routers/api/v1/packages/package.go
@@ -56,8 +56,8 @@ func ListPackages(ctx *context.APIContext) {
pvs, count, err := packages.SearchVersions(ctx, &packages.PackageSearchOptions{
OwnerID: ctx.Package.Owner.ID,
- Type: packageType,
- QueryName: query,
+ Type: packages.Type(packageType),
+ Name: packages.SearchValue{Value: query},
Paginator: &listOptions,
})
if err != nil {
diff --git a/routers/web/admin/packages.go b/routers/web/admin/packages.go
index 22be37526f..79bf025dd2 100644
--- a/routers/web/admin/packages.go
+++ b/routers/web/admin/packages.go
@@ -31,9 +31,9 @@ func Packages(ctx *context.Context) {
sort := ctx.FormTrim("sort")
pvs, total, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
- QueryName: query,
- Type: packageType,
- Sort: sort,
+ Type: packages_model.Type(packageType),
+ Name: packages_model.SearchValue{Value: query},
+ Sort: sort,
Paginator: &db.ListOptions{
PageSize: setting.UI.PackagesPagingNum,
Page: page,
diff --git a/routers/web/repo/packages.go b/routers/web/repo/packages.go
index f796bb0de5..b4db2d5787 100644
--- a/routers/web/repo/packages.go
+++ b/routers/web/repo/packages.go
@@ -32,10 +32,10 @@ func Packages(ctx *context.Context) {
PageSize: setting.UI.PackagesPagingNum,
Page: page,
},
- OwnerID: ctx.ContextUser.ID,
- RepoID: ctx.Repo.Repository.ID,
- QueryName: query,
- Type: packageType,
+ OwnerID: ctx.ContextUser.ID,
+ RepoID: ctx.Repo.Repository.ID,
+ Type: packages.Type(packageType),
+ Name: packages.SearchValue{Value: query},
})
if err != nil {
ctx.ServerError("SearchLatestVersions", err)
diff --git a/routers/web/user/package.go b/routers/web/user/package.go
index edbb4aadf6..7fecf9e768 100644
--- a/routers/web/user/package.go
+++ b/routers/web/user/package.go
@@ -43,9 +43,9 @@ func ListPackages(ctx *context.Context) {
PageSize: setting.UI.PackagesPagingNum,
Page: page,
},
- OwnerID: ctx.ContextUser.ID,
- Type: packageType,
- QueryName: query,
+ OwnerID: ctx.ContextUser.ID,
+ Type: packages_model.Type(packageType),
+ Name: packages_model.SearchValue{Value: query},
})
if err != nil {
ctx.ServerError("SearchLatestVersions", err)
@@ -219,9 +219,12 @@ func ListPackageVersions(ctx *context.Context) {
}
default:
pvs, total, err = packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
- Paginator: pagination,
- PackageID: p.ID,
- QueryVersion: query,
+ Paginator: pagination,
+ PackageID: p.ID,
+ Version: packages_model.SearchValue{
+ ExactMatch: false,
+ Value: query,
+ },
})
if err != nil {
ctx.ServerError("SearchVersions", err)