bump version; fix repo count metrics

This commit is contained in:
Brad Rydzewski 2017-07-25 15:32:22 -04:00
parent aadcde2b2c
commit 02a8a2a31f
11 changed files with 40 additions and 11 deletions

View file

@ -80,7 +80,7 @@ pipeline:
image: plugins/docker
repo: drone/drone
secrets: [ docker_username, docker_password ]
tag: [ 0.8, 0.8.0, 0.8.0-rc.2 ]
tag: [ 0.8, 0.8.0 ]
when:
event: tag
@ -89,7 +89,7 @@ pipeline:
repo: drone/agent
dockerfile: Dockerfile.agent
secrets: [ docker_username, docker_password ]
tag: [ 0.8, 0.8.0, 0.8.0-rc.2 ]
tag: [ 0.8, 0.8.0 ]
when:
event: tag

View file

@ -116,6 +116,13 @@ func (db *datastore) UpdateBuild(build *model.Build) error {
return meddler.Update(db, buildTable, build)
}
func (db *datastore) GetBuildCount() (count int, err error) {
err = db.QueryRow(
sql.Lookup(db.driver, "count-builds"),
).Scan(&count)
return
}
const buildTable = "builds"
const buildListQuery = `

View file

@ -264,14 +264,23 @@ func TestRepoCount(t *testing.T) {
Owner: "bradrydzewski",
Name: "drone",
FullName: "bradrydzewski/drone",
IsActive: true,
}
repo2 := &model.Repo{
Owner: "drone",
Name: "drone",
FullName: "drone/drone",
IsActive: true,
}
repo3 := &model.Repo{
Owner: "drone",
Name: "drone-ui",
FullName: "drone/drone-ui",
IsActive: false,
}
s.CreateRepo(repo1)
s.CreateRepo(repo2)
s.CreateRepo(repo3)
s.Exec("ANALYZE")
count, _ := s.GetRepoCount()
@ -294,6 +303,7 @@ func TestRepoBatch(t *testing.T) {
FullName: "foo/bar",
Owner: "foo",
Name: "bar",
IsActive: true,
}
err := s.CreateRepo(repo)
if err != nil {
@ -308,18 +318,21 @@ func TestRepoBatch(t *testing.T) {
FullName: "foo/bar",
Owner: "foo",
Name: "bar",
IsActive: true,
},
{
UserID: 1,
FullName: "bar/baz",
Owner: "bar",
Name: "baz",
IsActive: true,
},
{
UserID: 1,
FullName: "baz/qux",
Owner: "baz",
Name: "qux",
IsActive: true,
},
},
)

View file

@ -7,6 +7,7 @@ FROM users
SELECT count(1)
FROM repos
WHERE repo_active = true
-- name: count-builds

View file

@ -90,6 +90,7 @@ FROM users
var countRepos = `
SELECT count(1)
FROM repos
WHERE repo_active = true
`
var countBuilds = `

View file

@ -1,14 +1,15 @@
-- name: count-users
SELECT reltuples
FROM pg_class WHERE relname = 'users';
FROM pg_class WHERE relname = 'users'
-- name: count-repos
SELECT reltuples
FROM pg_class WHERE relname = 'repos';
SELECT count(1)
FROM repo
WHERE repo_active = 1
-- name: count-builds
SELECT reltuples
FROM pg_class WHERE relname = 'builds';
FROM pg_class WHERE relname = 'builds'

View file

@ -84,17 +84,18 @@ LIMIT 1
var countUsers = `
SELECT reltuples
FROM pg_class WHERE relname = 'users';
FROM pg_class WHERE relname = 'users'
`
var countRepos = `
SELECT reltuples
FROM pg_class WHERE relname = 'repos';
SELECT count(1)
FROM repo
WHERE repo_active = 1
`
var countBuilds = `
SELECT reltuples
FROM pg_class WHERE relname = 'builds';
FROM pg_class WHERE relname = 'builds'
`
var feedLatestBuild = `

View file

@ -7,6 +7,7 @@ FROM users
SELECT count(1)
FROM repos
WHERE repo_active = 1
-- name: count-builds

View file

@ -90,6 +90,7 @@ FROM users
var countRepos = `
SELECT count(1)
FROM repos
WHERE repo_active = 1
`
var countBuilds = `

View file

@ -72,6 +72,9 @@ type Store interface {
// GetBuildQueue gets a list of build in queue.
GetBuildQueue() ([]*model.Feed, error)
// GetBuildCount gets a count of all builds in the system.
GetBuildCount() (int, error)
// CreateBuild creates a new build and jobs.
CreateBuild(*model.Build, ...*model.Proc) error

View file

@ -10,7 +10,7 @@ var (
// VersionPatch is for backwards-compatible bug fixes
VersionPatch int64 = 0
// VersionPre indicates prerelease
VersionPre string = "rc.2"
VersionPre string
// VersionDev indicates development branch. Releases will be empty string.
VersionDev string
)