mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 22:23:50 +03:00
Fix condition for is_internal (#22095)
depends on #22094 Fixes https://codeberg.org/forgejo/forgejo/issues/77 The old logic did not consider `is_internal`. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
4fb2006ca1
commit
07461e18d3
2 changed files with 9 additions and 3 deletions
|
@ -302,9 +302,14 @@ func SearchLatestVersions(ctx context.Context, opts *PackageSearchOptions) ([]*P
|
||||||
cond := opts.toConds().
|
cond := opts.toConds().
|
||||||
And(builder.Expr("pv2.id IS NULL"))
|
And(builder.Expr("pv2.id IS NULL"))
|
||||||
|
|
||||||
|
joinCond := builder.Expr("package_version.package_id = pv2.package_id AND (package_version.created_unix < pv2.created_unix OR (package_version.created_unix = pv2.created_unix AND package_version.id < pv2.id))")
|
||||||
|
if !opts.IsInternal.IsNone() {
|
||||||
|
joinCond = joinCond.And(builder.Eq{"pv2.is_internal": opts.IsInternal.IsTrue()})
|
||||||
|
}
|
||||||
|
|
||||||
sess := db.GetEngine(ctx).
|
sess := db.GetEngine(ctx).
|
||||||
Table("package_version").
|
Table("package_version").
|
||||||
Join("LEFT", "package_version pv2", "package_version.package_id = pv2.package_id AND (package_version.created_unix < pv2.created_unix OR (package_version.created_unix = pv2.created_unix AND package_version.id < pv2.id))").
|
Join("LEFT", "package_version pv2", joinCond).
|
||||||
Join("INNER", "package", "package.id = package_version.package_id").
|
Join("INNER", "package", "package.id = package_version.package_id").
|
||||||
Where(cond)
|
Where(cond)
|
||||||
|
|
||||||
|
|
|
@ -405,8 +405,9 @@ func setPackageTag(tag string, pv *packages_model.PackageVersion, deleteOnly boo
|
||||||
|
|
||||||
func PackageSearch(ctx *context.Context) {
|
func PackageSearch(ctx *context.Context) {
|
||||||
pvs, total, err := packages_model.SearchLatestVersions(ctx, &packages_model.PackageSearchOptions{
|
pvs, total, err := packages_model.SearchLatestVersions(ctx, &packages_model.PackageSearchOptions{
|
||||||
OwnerID: ctx.Package.Owner.ID,
|
OwnerID: ctx.Package.Owner.ID,
|
||||||
Type: packages_model.TypeNpm,
|
Type: packages_model.TypeNpm,
|
||||||
|
IsInternal: util.OptionalBoolFalse,
|
||||||
Name: packages_model.SearchValue{
|
Name: packages_model.SearchValue{
|
||||||
ExactMatch: false,
|
ExactMatch: false,
|
||||||
Value: ctx.FormTrim("text"),
|
Value: ctx.FormTrim("text"),
|
||||||
|
|
Loading…
Reference in a new issue