mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-23 00:46:30 +00:00
Compare to pipeline created timestamp while using before/after filter (#3654)
This commit is contained in:
parent
2c3cd83402
commit
4b1ff6d1a7
2 changed files with 7 additions and 9 deletions
|
@ -59,11 +59,11 @@ func (s storage) GetPipelineList(repo *model.Repo, p *model.ListOptions, f *mode
|
|||
|
||||
if f != nil {
|
||||
if f.After != 0 {
|
||||
cond = cond.And(builder.Gt{"pipeline_started": f.After})
|
||||
cond = cond.And(builder.Gt{"pipeline_created": f.After})
|
||||
}
|
||||
|
||||
if f.Before != 0 {
|
||||
cond = cond.And(builder.Lt{"pipeline_started": f.Before})
|
||||
cond = cond.And(builder.Lt{"pipeline_created": f.Before})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -231,21 +231,19 @@ func TestPipelines(t *testing.T) {
|
|||
})
|
||||
|
||||
g.It("Should get filtered pipelines", func() {
|
||||
dt1, _ := time.Parse(time.RFC3339, "2023-01-15T15:00:00Z")
|
||||
pipeline1 := &model.Pipeline{
|
||||
RepoID: repo.ID,
|
||||
Started: dt1.Unix(),
|
||||
RepoID: repo.ID,
|
||||
}
|
||||
dt2, _ := time.Parse(time.RFC3339, "2023-01-15T16:30:00Z")
|
||||
pipeline2 := &model.Pipeline{
|
||||
RepoID: repo.ID,
|
||||
Started: dt2.Unix(),
|
||||
RepoID: repo.ID,
|
||||
}
|
||||
err1 := store.CreatePipeline(pipeline1, []*model.Step{}...)
|
||||
g.Assert(err1).IsNil()
|
||||
time.Sleep(1 * time.Second)
|
||||
before := time.Now().Unix()
|
||||
err2 := store.CreatePipeline(pipeline2, []*model.Step{}...)
|
||||
g.Assert(err2).IsNil()
|
||||
pipelines, err3 := store.GetPipelineList(&model.Repo{ID: 1}, &model.ListOptions{Page: 1, PerPage: 50}, &model.PipelineFilter{Before: dt2.Unix()})
|
||||
pipelines, err3 := store.GetPipelineList(&model.Repo{ID: 1}, &model.ListOptions{Page: 1, PerPage: 50}, &model.PipelineFilter{Before: before})
|
||||
g.Assert(err3).IsNil()
|
||||
g.Assert(len(pipelines)).Equal(1)
|
||||
g.Assert(pipelines[0].ID).Equal(pipeline1.ID)
|
||||
|
|
Loading…
Reference in a new issue