(fix) use zero offset when selecting users

This commit is contained in:
Brad Rydzewski 2021-09-13 14:34:00 -04:00
parent 95a8495796
commit 3f4edcfe46
3 changed files with 7 additions and 5 deletions

View file

@ -92,7 +92,7 @@ func (d *Datadog) do(ctx context.Context, unix int64) error {
}
userList, _ := d.users.ListRange(ctx, core.UserParams{
Sort: false,
Page: 1,
Page: 0,
Size: 5,
})
tags := createTags(d.config)

View file

@ -39,7 +39,7 @@ func TestDo(t *testing.T) {
users := mock.NewMockUserStore(controller)
users.EXPECT().Count(gomock.Any()).Return(int64(10), nil)
users.EXPECT().ListRange(gomock.Any(), gomock.Any()).Return([]*core.User{{Email: "jane@acme.com"}}, nil)
users.EXPECT().ListRange(gomock.Any(), gomock.Any()).Return([]*core.User{{Email: "jane@acme.com", Created: 1257894000}}, nil)
repos := mock.NewMockRepositoryStore(controller)
repos.EXPECT().Count(gomock.Any()).Return(int64(20), nil)
@ -75,7 +75,7 @@ var sample = `{
"points": [[915148800, 10]],
"type": "gauge",
"host": "test.example.com",
"tags": ["version:` + version.Version.String() + `","remote:github:cloud","scheduler:internal:agents","license:trial","installer:jane@acme.com"]
"tags": ["version:` + version.Version.String() + `","remote:github:cloud","scheduler:internal:agents","license:trial","installer:jane@acme.com","installed:2009-11-10T23:00:00Z"]
},
{
"metric": "drone.repos",

View file

@ -16,6 +16,7 @@ package sink
import (
"fmt"
"time"
"github.com/drone/drone/core"
"github.com/drone/drone/version"
@ -81,8 +82,9 @@ func createInstallerTags(users []*core.User) []string {
if len(user.Email) == 0 {
continue
}
tag := fmt.Sprintf("installer:%s", user.Email)
tags = append(tags, tag)
tag1 := fmt.Sprintf("installer:%s", user.Email)
tag2 := fmt.Sprintf("installed:%s", time.Unix(user.Created, 0).UTC().Format(time.RFC3339Nano))
tags = append(tags, tag1, tag2)
break
}
return tags