repos / git-pr

a self-hosted git collaboration server
git clone https://github.com/picosh/git-pr.git

commit
7e020cb
parent
df3b689
author
Eric Bower
date
2024-07-02 13:01:41 -0400 EDT
refactor: repo list pr should use last updated pr
2 files changed,  +3, -1
M db.go
M pr.go
M db.go
+2, -0
1@@ -38,6 +38,8 @@ type PatchRequest struct {
2 	Status    string    `db:"status"`
3 	CreatedAt time.Time `db:"created_at"`
4 	UpdatedAt time.Time `db:"updated_at"`
5+	// only used for aggregate queries
6+	LastUpdated string `db:"last_updated"`
7 }
8 
9 // Patch is a database model for a single entry in a patchset.
M pr.go
+1, -1
1@@ -159,7 +159,7 @@ func (pr PrCmd) GetRepos() ([]*Repo, error) {
2 func (pr PrCmd) GetReposWithLatestPr() ([]RepoWithLatestPr, error) {
3 	repos := []RepoWithLatestPr{}
4 	prs := []PatchRequest{}
5-	err := pr.Backend.DB.Select(&prs, "SELECT * FROM patch_requests GROUP BY repo_id ORDER BY updated_at DESC")
6+	err := pr.Backend.DB.Select(&prs, "SELECT *, max(updated_at) as last_updated FROM patch_requests GROUP BY repo_id")
7 	if err != nil {
8 		return repos, err
9 	}