aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2023-02-19 20:59:01 +0200
committerArthur Zamarin <arthurzam@gentoo.org>2023-02-19 22:12:32 +0200
commit4bafdd8e46e0e1991f443173c88fc8f896cac7da (patch)
tree7af2237936283ae47cc6f2f1b8e555fe8c2336ff /pkg/models
parentabout: show commit id (diff)
downloadsoko-4bafdd8e46e0e1991f443173c88fc8f896cac7da.tar.gz
soko-4bafdd8e46e0e1991f443173c88fc8f896cac7da.tar.bz2
soko-4bafdd8e46e0e1991f443173c88fc8f896cac7da.zip
upgrade to go-pg v10
- update go dependencies - update to not use helper functions (removed) - add some missing `rel` directives to models (adding all other creates issues with foreign keys) - `orm.Query` -> `pg.Query` Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'pkg/models')
-rw-r--r--pkg/models/commit.go10
-rw-r--r--pkg/models/package.go20
-rw-r--r--pkg/models/version.go22
3 files changed, 30 insertions, 22 deletions
diff --git a/pkg/models/commit.go b/pkg/models/commit.go
index d6fa710..7e6cd07 100644
--- a/pkg/models/commit.go
+++ b/pkg/models/commit.go
@@ -15,8 +15,8 @@ type Commit struct {
CommitterDate time.Time
Message string
ChangedFiles *ChangedFiles
- ChangedPackages []*Package `pg:"many2many:commit_to_packages,joinFK:package_atom"`
- ChangedVersions []*Version `pg:"many2many:commit_to_versions,joinFK:version_id"`
+ ChangedPackages []*Package `pg:"many2many:commit_to_packages,join_fk:package_atom"`
+ ChangedVersions []*Version `pg:"many2many:commit_to_versions,join_fk:version_id"`
KeywordChanges []*KeywordChange `pg:",fk:commit_id"`
}
@@ -34,11 +34,11 @@ type ChangedFile struct {
type KeywordChange struct {
Id string `pg:",pk"`
CommitId string
- Commit *Commit `pg:",fk:commit_id"`
+ Commit *Commit `pg:",fk:commit_id,rel:has-one"`
VersionId string
- Version *Version `pg:",fk:version_id"`
+ Version *Version `pg:",fk:version_id,rel:has-one"`
PackageId string
- Package *Package `pg:",fk:package_id"`
+ Package *Package `pg:",fk:package_id,rel:has-one"`
Added []string
Stabilized []string
All []string
diff --git a/pkg/models/package.go b/pkg/models/package.go
index 439480a..e83de85 100644
--- a/pkg/models/package.go
+++ b/pkg/models/package.go
@@ -8,17 +8,17 @@ type Package struct {
Atom string `pg:",pk"`
Category string
Name string
- Versions []*Version `pg:",fk:atom"`
+ Versions []*Version `pg:",fk:atom,rel:has-many"`
Longdescription string
Maintainers []*Maintainer
Upstream Upstream
- Commits []*Commit `pg:"many2many:commit_to_packages,joinFK:commit_id"`
+ Commits []*Commit `pg:"many2many:commit_to_packages,join_fk:commit_id"`
PrecedingCommits int `pg:",use_zero"`
- PkgCheckResults []*PkgCheckResult `pg:",fk:atom"`
- Outdated []*OutdatedPackages `pg:",fk:atom"`
- Bugs []*Bug `pg:"many2many:package_to_bugs,joinFK:bug_id"`
- PullRequests []*GithubPullRequest `pg:"many2many:package_to_github_pull_requests,joinFK:github_pull_request_id"`
- ReverseDependencies []*ReverseDependency `pg:",fk:atom"`
+ PkgCheckResults []*PkgCheckResult `pg:",fk:atom,rel:has-many"`
+ Outdated []*OutdatedPackages `pg:",fk:atom,rel:has-many"`
+ Bugs []*Bug `pg:"many2many:package_to_bugs,join_fk:bug_id"`
+ PullRequests []*GithubPullRequest `pg:"many2many:package_to_github_pull_requests,join_fk:github_pull_request_id"`
+ ReverseDependencies []*ReverseDependency `pg:",fk:atom,rel:has-many"`
}
type Maintainer struct {
@@ -27,10 +27,10 @@ type Maintainer struct {
Type string
Restrict string
PackagesInformation MaintainerPackagesInformation
- // In case the maintainer type is "project", Project will point to the project
- Project Project `pg:",fk:email"`
+ // In case the maintainer type is "project", Project will posokoint to the project
+ Project Project `pg:",fk:email,rel:has-one"`
// In case the maintainer type is not "project", Projects will point to the projects the maintainer is member of
- Projects []*Project `pg:"many2many:maintainer_to_projects,joinFK:project_email"`
+ Projects []*Project `pg:"many2many:maintainer_to_projects,join_fk:project_email"`
}
type MaintainerPackagesInformation struct {
diff --git a/pkg/models/version.go b/pkg/models/version.go
index 54f5a5b..c2d5fbf 100644
--- a/pkg/models/version.go
+++ b/pkg/models/version.go
@@ -27,11 +27,11 @@ type Version struct {
Homepage []string
License string
Description string
- Commits []*Commit `pg:"many2many:commit_to_versions,joinFK:commit_id"`
- Masks []*Mask `pg:"many2many:mask_to_versions,joinFK:mask_versions"`
+ Commits []*Commit `pg:"many2many:commit_to_versions,join_fk:commit_id"`
+ Masks []*Mask `pg:"many2many:mask_to_versions,join_fk:mask_versions"`
PkgCheckResults []*PkgCheckResult `pg:",fk:cpv"`
Dependencies []*ReverseDependency `pg:",fk:reverse_dependency_version"`
- Bugs []*Bug `pg:"many2many:version_to_bugs,joinFK:bug_id"`
+ Bugs []*Bug `pg:"many2many:version_to_bugs,join_fk:bug_id"`
}
func (v Version) BuildDepMap() map[string]map[string]string {
@@ -212,9 +212,13 @@ func (v *Version) computeVersionIdentifier() VersionIdentifier {
}
// getNumericPart returns the numeric part of the version, that is:
-// version, letter
+//
+// version, letter
+//
// i.e. 10.3.18a becomes
-// 10.3.18, a
+//
+// 10.3.18, a
+//
// The first returned string is the version and the second if the (optional) letter
func getNumericPart(str string) (string, string) {
if unicode.IsLetter(rune(str[len(str)-1])) {
@@ -225,7 +229,9 @@ func getNumericPart(str string) (string, string) {
// getSuffix creates a VersionSuffix based on the given string.
// The given string is expected to be look like
-// pre20190518
+//
+// pre20190518
+//
// for instance. The suffix named as well as the following number
// will be parsed and returned as VersionSuffix
func getSuffix(str string) *VersionSuffix {
@@ -253,7 +259,9 @@ func isRevision(str string) bool {
// getSuffixOrder returns an int for the given suffix,
// based on the following:
-// _alpha < _beta < _pre < _rc < _p < none
+//
+// _alpha < _beta < _pre < _rc < _p < none
+//
// as defined in the Package Manager Specification (PMS)
func getSuffixOrder(suffix string) int {
if suffix == "p" {