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

View file

@ -116,6 +116,13 @@ func (db *datastore) UpdateBuild(build *model.Build) error {
return meddler.Update(db, buildTable, build) 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 buildTable = "builds"
const buildListQuery = ` const buildListQuery = `

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -72,6 +72,9 @@ type Store interface {
// GetBuildQueue gets a list of build in queue. // GetBuildQueue gets a list of build in queue.
GetBuildQueue() ([]*model.Feed, error) 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 creates a new build and jobs.
CreateBuild(*model.Build, ...*model.Proc) error CreateBuild(*model.Build, ...*model.Proc) error

View file

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