add page param for getting build list with offset
This commit is contained in:
parent
5722ce410a
commit
af76d46b53
3 changed files with 7 additions and 7 deletions
|
@ -45,9 +45,9 @@ func (db *datastore) GetBuildLastBefore(repo *model.Repo, branch string, num int
|
||||||
return build, err
|
return build, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *datastore) GetBuildList(repo *model.Repo) ([]*model.Build, error) {
|
func (db *datastore) GetBuildList(repo *model.Repo, page int) ([]*model.Build, error) {
|
||||||
var builds = []*model.Build{}
|
var builds = []*model.Build{}
|
||||||
var err = meddler.QueryAll(db, &builds, rebind(buildListQuery), repo.ID)
|
var err = meddler.QueryAll(db, &builds, rebind(buildListQuery), repo.ID, 50*(page-1))
|
||||||
return builds, err
|
return builds, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ SELECT *
|
||||||
FROM builds
|
FROM builds
|
||||||
WHERE build_repo_id = ?
|
WHERE build_repo_id = ?
|
||||||
ORDER BY build_number DESC
|
ORDER BY build_number DESC
|
||||||
LIMIT 50
|
LIMIT 50 OFFSET ?
|
||||||
`
|
`
|
||||||
|
|
||||||
const buildNumberQuery = `
|
const buildNumberQuery = `
|
||||||
|
|
|
@ -247,7 +247,7 @@ func TestBuilds(t *testing.T) {
|
||||||
}
|
}
|
||||||
s.CreateBuild(build1, []*model.Proc{}...)
|
s.CreateBuild(build1, []*model.Proc{}...)
|
||||||
s.CreateBuild(build2, []*model.Proc{}...)
|
s.CreateBuild(build2, []*model.Proc{}...)
|
||||||
builds, err := s.GetBuildList(&model.Repo{ID: 1})
|
builds, err := s.GetBuildList(&model.Repo{ID: 1}, 1)
|
||||||
g.Assert(err == nil).IsTrue()
|
g.Assert(err == nil).IsTrue()
|
||||||
g.Assert(len(builds)).Equal(2)
|
g.Assert(len(builds)).Equal(2)
|
||||||
g.Assert(builds[0].ID).Equal(build2.ID)
|
g.Assert(builds[0].ID).Equal(build2.ID)
|
||||||
|
|
|
@ -67,7 +67,7 @@ type Store interface {
|
||||||
GetBuildLastBefore(*model.Repo, string, int64) (*model.Build, error)
|
GetBuildLastBefore(*model.Repo, string, int64) (*model.Build, error)
|
||||||
|
|
||||||
// GetBuildList gets a list of builds for the repository
|
// GetBuildList gets a list of builds for the repository
|
||||||
GetBuildList(*model.Repo) ([]*model.Build, error)
|
GetBuildList(*model.Repo, int) ([]*model.Build, error)
|
||||||
|
|
||||||
// GetBuildQueue gets a list of build in queue.
|
// GetBuildQueue gets a list of build in queue.
|
||||||
GetBuildQueue() ([]*model.Feed, error)
|
GetBuildQueue() ([]*model.Feed, error)
|
||||||
|
@ -223,8 +223,8 @@ func GetBuildLastBefore(c context.Context, repo *model.Repo, branch string, numb
|
||||||
return FromContext(c).GetBuildLastBefore(repo, branch, number)
|
return FromContext(c).GetBuildLastBefore(repo, branch, number)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBuildList(c context.Context, repo *model.Repo) ([]*model.Build, error) {
|
func GetBuildList(c context.Context, repo *model.Repo, page int) ([]*model.Build, error) {
|
||||||
return FromContext(c).GetBuildList(repo)
|
return FromContext(c).GetBuildList(repo, page)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBuildQueue(c context.Context) ([]*model.Feed, error) {
|
func GetBuildQueue(c context.Context) ([]*model.Feed, error) {
|
||||||
|
|
Loading…
Reference in a new issue