Skip to content

Commit

Permalink
Merge pull request #238 from CircleCI-Public/CIRCLE-15460-orb-list-js…
Browse files Browse the repository at this point in the history
…on-stats

Show statistics in `orb list --json`
  • Loading branch information
Zachary Scott authored Dec 25, 2018
2 parents f354ca5 + 365ac9e commit 94e0863
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 59 deletions.
14 changes: 7 additions & 7 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ func (orbs *OrbsForListing) SortBy(sortBy string) {
type OrbBase struct {
Name string `json:"name"`
HighestVersion string `json:"version"`
Versions []struct {
Statistics struct {
Last30DaysBuildCount int `json:"last30DaysBuildCount"`
Last30DaysProjectCount int `json:"last30DaysProjectCount"`
Last30DaysOrganizationCount int `json:"last30DaysOrganizationCount"`
} `json:"statistics"`
Versions []struct {
Version string `json:"version"`
Source string `json:"source"`
} `json:"versions"`
Expand All @@ -247,12 +252,6 @@ type OrbBase struct {
type OrbWithData struct {
OrbBase

Statistics struct {
Last30DaysBuildCount int
Last30DaysProjectCount int
Last30DaysOrganizationCount int
}

Commands map[string]OrbElement
Jobs map[string]OrbElement
Executors map[string]OrbElement
Expand All @@ -264,6 +263,7 @@ func (orb OrbWithData) MarshalJSON() ([]byte, error) {
orbForJSON := OrbBase{
orb.Name,
orb.HighestVersion,
orb.Statistics,
orb.Versions,
}

Expand Down
40 changes: 40 additions & 0 deletions cmd/testdata/gql_orb_list/pretty_json_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"orbs": [
{
"name": "circleci/codecov-clojure",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.3",
"versions": [
{
Expand All @@ -12,6 +17,11 @@
},
{
"name": "circleci/gradle",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.1",
"versions": [
{
Expand All @@ -22,6 +32,11 @@
},
{
"name": "eric-hu/delivery-test",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "1.0.4",
"versions": [
{
Expand All @@ -32,6 +47,11 @@
},
{
"name": "ndintenfass/build-utils",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.2",
"versions": [
{
Expand All @@ -42,6 +62,11 @@
},
{
"name": "test1/foo",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.0",
"versions": [
{
Expand All @@ -52,6 +77,11 @@
},
{
"name": "test1/new-orb",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.1",
"versions": [
{
Expand All @@ -62,6 +92,11 @@
},
{
"name": "test1/so-fly",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.0",
"versions": [
{
Expand All @@ -72,6 +107,11 @@
},
{
"name": "test/test",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.3",
"versions": [
{
Expand Down
29 changes: 17 additions & 12 deletions cmd/testdata/gql_orb_list_details/pretty_json_output.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{
"orbs": [
{
"name": "foo/test",
"version": "0.7.0",
"versions": [
{
"version": "0.7.0",
"source": "version: 2.1\norbs:\n foo:\n commands:\n foo:\n steps:\n - checkout\ncommands:\n myfoo: foo/foo\n bar:\n parameters:\n hello:\n type: string\n default: world\n steps:\n - echo \u003c\u003cparameters.hello\u003e\u003e\n\nexecutors:\n default:\n parameters:\n tag:\n type: string\n default: \"curl-browsers\"\n docker:\n - image: circleci/buildpack-deps:\u003c\u003c parameters.tag \u003e\u003e\n\njobs:\n hello-build:\n executor: default\n steps:\n - echo:\n message: \"Hello, build!\"\n"
}
]
}
]
"orbs": [
{
"name": "foo/test",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.7.0",
"versions": [
{
"version": "0.7.0",
"source": "version: 2.1\norbs:\n foo:\n commands:\n foo:\n steps:\n - checkout\ncommands:\n myfoo: foo/foo\n bar:\n parameters:\n hello:\n type: string\n default: world\n steps:\n - echo \u003c\u003cparameters.hello\u003e\u003e\n\nexecutors:\n default:\n parameters:\n tag:\n type: string\n default: \"curl-browsers\"\n docker:\n - image: circleci/buildpack-deps:\u003c\u003c parameters.tag \u003e\u003e\n\njobs:\n hello-build:\n executor: default\n steps:\n - echo:\n message: \"Hello, build!\"\n"
}
]
}
]
}
55 changes: 55 additions & 0 deletions cmd/testdata/gql_orb_list_uncertified/pretty_json_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"orbs": [
{
"name": "circleci/codecov-clojure",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.4",
"versions": [
{
Expand All @@ -12,6 +17,11 @@
},
{
"name": "circleci/gradle",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.1",
"versions": [
{
Expand All @@ -22,6 +32,11 @@
},
{
"name": "circleci/rollbar",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.1",
"versions": [
{
Expand All @@ -32,6 +47,11 @@
},
{
"name": "eric-hu/delivery-test",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "1.0.4",
"versions": [
{
Expand All @@ -42,6 +62,11 @@
},
{
"name": "hannah/foo",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.0",
"versions": [
{
Expand All @@ -52,6 +77,11 @@
},
{
"name": "hannah/new-orb",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.1",
"versions": [
{
Expand All @@ -62,6 +92,11 @@
},
{
"name": "hannah/so-fly",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.0",
"versions": [
{
Expand All @@ -72,6 +107,11 @@
},
{
"name": "ndintenfass/build-utils",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.2",
"versions": [
{
Expand All @@ -82,6 +122,11 @@
},
{
"name": "test/test",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.0.3",
"versions": [
{
Expand All @@ -92,6 +137,11 @@
},
{
"name": "zzak/test4",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.1.0",
"versions": [
{
Expand All @@ -102,6 +152,11 @@
},
{
"name": "zzak/testing",
"statistics": {
"last30DaysBuildCount": 0,
"last30DaysProjectCount": 0,
"last30DaysOrganizationCount": 0
},
"version": "0.2.0",
"versions": [
{
Expand Down
Loading

0 comments on commit 94e0863

Please sign in to comment.