summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-12-14 10:16:01 +0100
committerGitHub <noreply@github.com>2022-12-14 17:16:01 +0800
commit07461e18d33c78de2d6ae028f8ddba72f971db81 (patch)
treeeb3f65c4eff9b9732dfa69bc49d37e44e8f6b90a /models
parent4fb2006ca1cba98fe3851901982a3ecab252cfe3 (diff)
downloadgitea-07461e18d33c78de2d6ae028f8ddba72f971db81.tar.gz
gitea-07461e18d33c78de2d6ae028f8ddba72f971db81.zip
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>
Diffstat (limited to 'models')
-rw-r--r--models/packages/package_version.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/models/packages/package_version.go b/models/packages/package_version.go
index a2a8a45d8f..928f9d47d6 100644
--- a/models/packages/package_version.go
+++ b/models/packages/package_version.go
@@ -302,9 +302,14 @@ func SearchLatestVersions(ctx context.Context, opts *PackageSearchOptions) ([]*P
cond := opts.toConds().
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).
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").
Where(cond)