{"action":"created","comment":{"url":"https://api.github.com/repos/dgryski/carbonapi/pulls/comments/80568963","id":80568963,"diff_hunk":"@@ -3266,6 +3267,82 @@ func EvalExpr(e *expr, from, until int32, values map[MetricRequest][]*MetricData\n \t\t}\n \n \t\treturn results, nil\n+\n+\tcase \"cactiStyle\": // cactiStyle(seriesList, system=None, units=None)\n+\t\t// Get the series data\n+\t\toriginal, err := getSeriesArg(e.args[0], from, until, values)\n+\t\tif err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n+\n+\t\t// Get the arguments\n+\t\tsystem, err := getStringNamedOrPosArgDefault(e, \"system\", 1, \"\")\n+\t\tif err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n+\t\tunit, err := getStringNamedOrPosArgDefault(e, \"units\", 2, \"\")\n+\t\tif err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n+\n+\t\t// Deal with each of the series\n+\t\tfor _, a := range original {\n+\t\t\t// Calculate min, max, current\n+\t\t\t//\n+\t\t\t// This saves calling summarizeValues 3 times and looping over\n+\t\t\t// the metrics 3 times\n+\t\t\t//\n+\t\t\t// For min:\n+\t\t\t// Ignoring any absent values and inf (if we have a value)\n+\t\t\t// Using summarizeValues(\"min\", ...) results in incorrect values, when absent\n+\t\t\t// values are present\n+\t\t\t//\n+\t\t\tval_min := math.Inf(-1)\n+\t\t\tval_current := math.Inf(-1)\n+\t\t\tval_max := math.Inf(-1)\n+\t\t\tfor i, av := range a.GetValues() {\n+\t\t\t\tif !a.IsAbsent[i] && (val_min == math.Inf(-1) || av < val_min) {\n+\t\t\t\t\tval_min = av\n+\t\t\t\t}\n+\t\t\t\tif !a.IsAbsent[i] && av > val_max {\n+\t\t\t\t\tval_max = av\n+\t\t\t\t}\n+\t\t\t\tval_current = av\n+\t\t\t}\n+\n+\t\t\t// Format the output correctly\n+\t\t\tmin := \"\"\n+\t\t\tmax := \"\"\n+\t\t\tcurrent := \"\"\n+\t\t\tif system == \"si\" {\n+\t\t\t\tmv, mf := humanize.ComputeSI(val_min)\n+\t\t\t\txv, xf := humanize.ComputeSI(val_max)\n+\t\t\t\tcv, cf := humanize.ComputeSI(val_current)\n+\n+\t\t\t\tmin = fmt.Sprintf(\"%.0f%s\", mv, mf)\n+\t\t\t\tmax = fmt.Sprintf(\"%.0f%s\", xv, xf)\n+\t\t\t\tcurrent = fmt.Sprintf(\"%.0f%s\", cv, cf)\n+\n+\t\t\t} else if system == \"\" {\n+\t\t\t\tmin = fmt.Sprintf(\"%.0f\", val_min)\n+\t\t\t\tmax = fmt.Sprintf(\"%.0f\", val_max)\n+\t\t\t\tcurrent = fmt.Sprintf(\"%.0f\", val_current)\n+\n+\t\t\t} else {\n+\t\t\t\treturn nil, fmt.Errorf(\"%s is not supported for system\", system)\n+\t\t\t}\n+\n+\t\t\t// Append the unit if specified\n+\t\t\tif len(unit) > 0 {\n+\t\t\t\tmin = fmt.Sprintf(\"%s %s\", min, unit)\n+\t\t\t\tmax = fmt.Sprintf(\"%s %s\", max, unit)\n+\t\t\t\tcurrent = fmt.Sprintf(\"%s %s\", current, unit)\n+\t\t\t}\n+\n+\t\t\ta.Name = proto.String(fmt.Sprintf(\"%s Current: %s Max: %s Min: %s\", *a.Name, current, max, min))","path":"expr/expr.go","position":84,"original_position":84,"commit_id":"d3730ee2eafb3af141d5fcdf1a4d4b4ec1abdf9a","original_commit_id":"d3730ee2eafb3af141d5fcdf1a4d4b4ec1abdf9a","user":{"login":"nnuss","id":7057945,"avatar_url":"https://avatars.githubusercontent.com/u/7057945?v=3","gravatar_id":"","url":"https://api.github.com/users/nnuss","html_url":"https://github.com/nnuss","followers_url":"https://api.github.com/users/nnuss/followers","following_url":"https://api.github.com/users/nnuss/following{/other_user}","gists_url":"https://api.github.com/users/nnuss/gists{/gist_id}","starred_url":"https://api.github.com/users/nnuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nnuss/subscriptions","organizations_url":"https://api.github.com/users/nnuss/orgs","repos_url":"https://api.github.com/users/nnuss/repos","events_url":"https://api.github.com/users/nnuss/events{/privacy}","received_events_url":"https://api.github.com/users/nnuss/received_events","type":"User","site_admin":false},"body":"We don't mangle the name in-place (it messes up the tests for one).\r\nInstead follow our convention of:\r\n\r\n```go\r\n    //above the for loop\r\n    var results []*MetricData\r\n\r\n    for _, a := range original {\r\n        ...\r\n    \r\n        r := *a\r\n        r.Name = proto.String(fmt.Sprintf(\"%s Current: %s Max: %s Min: %s\", *a.Name, current, max, min))\r\n        results = append(results, &r)\r\n    }\r\n    return results, nil\r\n```","created_at":"2016-09-26T20:46:57Z","updated_at":"2016-09-26T20:52:55Z","html_url":"https://github.com/dgryski/carbonapi/pull/159#discussion_r80568963","pull_request_url":"https://api.github.com/repos/dgryski/carbonapi/pulls/159","_links":{"self":{"href":"https://api.github.com/repos/dgryski/carbonapi/pulls/comments/80568963"},"html":{"href":"https://github.com/dgryski/carbonapi/pull/159#discussion_r80568963"},"pull_request":{"href":"https://api.github.com/repos/dgryski/carbonapi/pulls/159"}}},"pull_request":{"url":"https://api.github.com/repos/dgryski/carbonapi/pulls/159","id":85479643,"html_url":"https://github.com/dgryski/carbonapi/pull/159","diff_url":"https://github.com/dgryski/carbonapi/pull/159.diff","patch_url":"https://github.com/dgryski/carbonapi/pull/159.patch","issue_url":"https://api.github.com/repos/dgryski/carbonapi/issues/159","number":159,"state":"open","locked":false,"title":"Add cactiStyle function with 'si' support for #156","user":{"login":"DamianZaremba","id":142120,"avatar_url":"https://avatars.githubusercontent.com/u/142120?v=3","gravatar_id":"","url":"https://api.github.com/users/DamianZaremba","html_url":"https://github.com/DamianZaremba","followers_url":"https://api.github.com/users/DamianZaremba/followers","following_url":"https://api.github.com/users/DamianZaremba/following{/other_user}","gists_url":"https://api.github.com/users/DamianZaremba/gists{/gist_id}","starred_url":"https://api.github.com/users/DamianZaremba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DamianZaremba/subscriptions","organizations_url":"https://api.github.com/users/DamianZaremba/orgs","repos_url":"https://api.github.com/users/DamianZaremba/repos","events_url":"https://api.github.com/users/DamianZaremba/events{/privacy}","received_events_url":"https://api.github.com/users/DamianZaremba/received_events","type":"User","site_admin":false},"body":"Adds a cactiStyle function, supporting:\r\n\r\n- no unit standardisation or 'si' unit standardisation\r\n- arbitrary unit postfixing\r\n\r\nIt does not support:\r\n\r\n- 'binary' unit standardisation (this should be easy enough to add, but I don't really have test examples for it)\r\n\r\nThis has been 'roughly' tested, using some internal pre-existing render parameters. Further testing needs to take place, to ensure there are no rounding or other not-so-obvious issues present.\r\n\r\nTODO:\r\n\r\n- Implement the 'binary' unit standardisation?\r\n- Fix the unit tests\r\n\r\nOpening a PR for the purposes of feedback.","created_at":"2016-09-15T21:01:42Z","updated_at":"2016-09-26T20:52:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f3f9ca48742de8e8a16eb76145aa4c103edcd2ca","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dgryski/carbonapi/pulls/159/commits","review_comments_url":"https://api.github.com/repos/dgryski/carbonapi/pulls/159/comments","review_comment_url":"https://api.github.com/repos/dgryski/carbonapi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dgryski/carbonapi/issues/159/comments","statuses_url":"https://api.github.com/repos/dgryski/carbonapi/statuses/d3730ee2eafb3af141d5fcdf1a4d4b4ec1abdf9a","head":{"label":"DamianZaremba:master","ref":"master","sha":"d3730ee2eafb3af141d5fcdf1a4d4b4ec1abdf9a","user":{"login":"DamianZaremba","id":142120,"avatar_url":"https://avatars.githubusercontent.com/u/142120?v=3","gravatar_id":"","url":"https://api.github.com/users/DamianZaremba","html_url":"https://github.com/DamianZaremba","followers_url":"https://api.github.com/users/DamianZaremba/followers","following_url":"https://api.github.com/users/DamianZaremba/following{/other_user}","gists_url":"https://api.github.com/users/DamianZaremba/gists{/gist_id}","starred_url":"https://api.github.com/users/DamianZaremba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DamianZaremba/subscriptions","organizations_url":"https://api.github.com/users/DamianZaremba/orgs","repos_url":"https://api.github.com/users/DamianZaremba/repos","events_url":"https://api.github.com/users/DamianZaremba/events{/privacy}","received_events_url":"https://api.github.com/users/DamianZaremba/received_events","type":"User","site_admin":false},"repo":{"id":68152182,"name":"carbonapi","full_name":"DamianZaremba/carbonapi","owner":{"login":"DamianZaremba","id":142120,"avatar_url":"https://avatars.githubusercontent.com/u/142120?v=3","gravatar_id":"","url":"https://api.github.com/users/DamianZaremba","html_url":"https://github.com/DamianZaremba","followers_url":"https://api.github.com/users/DamianZaremba/followers","following_url":"https://api.github.com/users/DamianZaremba/following{/other_user}","gists_url":"https://api.github.com/users/DamianZaremba/gists{/gist_id}","starred_url":"https://api.github.com/users/DamianZaremba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DamianZaremba/subscriptions","organizations_url":"https://api.github.com/users/DamianZaremba/orgs","repos_url":"https://api.github.com/users/DamianZaremba/repos","events_url":"https://api.github.com/users/DamianZaremba/events{/privacy}","received_events_url":"https://api.github.com/users/DamianZaremba/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DamianZaremba/carbonapi","description":"API server for github.com/dgryski/carbonzipper","fork":true,"url":"https://api.github.com/repos/DamianZaremba/carbonapi","forks_url":"https://api.github.com/repos/DamianZaremba/carbonapi/forks","keys_url":"https://api.github.com/repos/DamianZaremba/carbonapi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DamianZaremba/carbonapi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DamianZaremba/carbonapi/teams","hooks_url":"https://api.github.com/repos/DamianZaremba/carbonapi/hooks","issue_events_url":"https://api.github.com/repos/DamianZaremba/carbonapi/issues/events{/number}","events_url":"https://api.github.com/repos/DamianZaremba/carbonapi/events","assignees_url":"https://api.github.com/repos/DamianZaremba/carbonapi/assignees{/user}","branches_url":"https://api.github.com/repos/DamianZaremba/carbonapi/branches{/branch}","tags_url":"https://api.github.com/repos/DamianZaremba/carbonapi/tags","blobs_url":"https://api.github.com/repos/DamianZaremba/carbonapi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DamianZaremba/carbonapi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DamianZaremba/carbonapi/git/refs{/sha}","trees_url":"https://api.github.com/repos/DamianZaremba/carbonapi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DamianZaremba/carbonapi/statuses/{sha}","languages_url":"https://api.github.com/repos/DamianZaremba/carbonapi/languages","stargazers_url":"https://api.github.com/repos/DamianZaremba/carbonapi/stargazers","contributors_url":"https://api.github.com/repos/DamianZaremba/carbonapi/contributors","subscribers_url":"https://api.github.com/repos/DamianZaremba/carbonapi/subscribers","subscription_url":"https://api.github.com/repos/DamianZaremba/carbonapi/subscription","commits_url":"https://api.github.com/repos/DamianZaremba/carbonapi/commits{/sha}","git_commits_url":"https://api.github.com/repos/DamianZaremba/carbonapi/git/commits{/sha}","comments_url":"https://api.github.com/repos/DamianZaremba/carbonapi/comments{/number}","issue_comment_url":"https://api.github.com/repos/DamianZaremba/carbonapi/issues/comments{/number}","contents_url":"https://api.github.com/repos/DamianZaremba/carbonapi/contents/{+path}","compare_url":"https://api.github.com/repos/DamianZaremba/carbonapi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DamianZaremba/carbonapi/merges","archive_url":"https://api.github.com/repos/DamianZaremba/carbonapi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DamianZaremba/carbonapi/downloads","issues_url":"https://api.github.com/repos/DamianZaremba/carbonapi/issues{/number}","pulls_url":"https://api.github.com/repos/DamianZaremba/carbonapi/pulls{/number}","milestones_url":"https://api.github.com/repos/DamianZaremba/carbonapi/milestones{/number}","notifications_url":"https://api.github.com/repos/DamianZaremba/carbonapi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DamianZaremba/carbonapi/labels{/name}","releases_url":"https://api.github.com/repos/DamianZaremba/carbonapi/releases{/id}","deployments_url":"https://api.github.com/repos/DamianZaremba/carbonapi/deployments","created_at":"2016-09-13T22:21:39Z","updated_at":"2016-09-13T22:21:40Z","pushed_at":"2016-09-25T15:15:24Z","git_url":"git://github.com/DamianZaremba/carbonapi.git","ssh_url":"git@github.com:DamianZaremba/carbonapi.git","clone_url":"https://github.com/DamianZaremba/carbonapi.git","svn_url":"https://github.com/DamianZaremba/carbonapi","homepage":"","size":914,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dgryski:master","ref":"master","sha":"cf0e605c83e2813f4eb491f9c91bbc0d8d6d9228","user":{"login":"dgryski","id":970862,"avatar_url":"https://avatars.githubusercontent.com/u/970862?v=3","gravatar_id":"","url":"https://api.github.com/users/dgryski","html_url":"https://github.com/dgryski","followers_url":"https://api.github.com/users/dgryski/followers","following_url":"https://api.github.com/users/dgryski/following{/other_user}","gists_url":"https://api.github.com/users/dgryski/gists{/gist_id}","starred_url":"https://api.github.com/users/dgryski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgryski/subscriptions","organizations_url":"https://api.github.com/users/dgryski/orgs","repos_url":"https://api.github.com/users/dgryski/repos","events_url":"https://api.github.com/users/dgryski/events{/privacy}","received_events_url":"https://api.github.com/users/dgryski/received_events","type":"User","site_admin":false},"repo":{"id":22234992,"name":"carbonapi","full_name":"dgryski/carbonapi","owner":{"login":"dgryski","id":970862,"avatar_url":"https://avatars.githubusercontent.com/u/970862?v=3","gravatar_id":"","url":"https://api.github.com/users/dgryski","html_url":"https://github.com/dgryski","followers_url":"https://api.github.com/users/dgryski/followers","following_url":"https://api.github.com/users/dgryski/following{/other_user}","gists_url":"https://api.github.com/users/dgryski/gists{/gist_id}","starred_url":"https://api.github.com/users/dgryski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgryski/subscriptions","organizations_url":"https://api.github.com/users/dgryski/orgs","repos_url":"https://api.github.com/users/dgryski/repos","events_url":"https://api.github.com/users/dgryski/events{/privacy}","received_events_url":"https://api.github.com/users/dgryski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dgryski/carbonapi","description":"API server for github.com/dgryski/carbonzipper","fork":false,"url":"https://api.github.com/repos/dgryski/carbonapi","forks_url":"https://api.github.com/repos/dgryski/carbonapi/forks","keys_url":"https://api.github.com/repos/dgryski/carbonapi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dgryski/carbonapi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dgryski/carbonapi/teams","hooks_url":"https://api.github.com/repos/dgryski/carbonapi/hooks","issue_events_url":"https://api.github.com/repos/dgryski/carbonapi/issues/events{/number}","events_url":"https://api.github.com/repos/dgryski/carbonapi/events","assignees_url":"https://api.github.com/repos/dgryski/carbonapi/assignees{/user}","branches_url":"https://api.github.com/repos/dgryski/carbonapi/branches{/branch}","tags_url":"https://api.github.com/repos/dgryski/carbonapi/tags","blobs_url":"https://api.github.com/repos/dgryski/carbonapi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dgryski/carbonapi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dgryski/carbonapi/git/refs{/sha}","trees_url":"https://api.github.com/repos/dgryski/carbonapi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dgryski/carbonapi/statuses/{sha}","languages_url":"https://api.github.com/repos/dgryski/carbonapi/languages","stargazers_url":"https://api.github.com/repos/dgryski/carbonapi/stargazers","contributors_url":"https://api.github.com/repos/dgryski/carbonapi/contributors","subscribers_url":"https://api.github.com/repos/dgryski/carbonapi/subscribers","subscription_url":"https://api.github.com/repos/dgryski/carbonapi/subscription","commits_url":"https://api.github.com/repos/dgryski/carbonapi/commits{/sha}","git_commits_url":"https://api.github.com/repos/dgryski/carbonapi/git/commits{/sha}","comments_url":"https://api.github.com/repos/dgryski/carbonapi/comments{/number}","issue_comment_url":"https://api.github.com/repos/dgryski/carbonapi/issues/comments{/number}","contents_url":"https://api.github.com/repos/dgryski/carbonapi/contents/{+path}","compare_url":"https://api.github.com/repos/dgryski/carbonapi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dgryski/carbonapi/merges","archive_url":"https://api.github.com/repos/dgryski/carbonapi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dgryski/carbonapi/downloads","issues_url":"https://api.github.com/repos/dgryski/carbonapi/issues{/number}","pulls_url":"https://api.github.com/repos/dgryski/carbonapi/pulls{/number}","milestones_url":"https://api.github.com/repos/dgryski/carbonapi/milestones{/number}","notifications_url":"https://api.github.com/repos/dgryski/carbonapi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dgryski/carbonapi/labels{/name}","releases_url":"https://api.github.com/repos/dgryski/carbonapi/releases{/id}","deployments_url":"https://api.github.com/repos/dgryski/carbonapi/deployments","created_at":"2014-07-24T22:46:07Z","updated_at":"2016-09-23T11:50:33Z","pushed_at":"2016-09-25T15:15:24Z","git_url":"git://github.com/dgryski/carbonapi.git","ssh_url":"git@github.com:dgryski/carbonapi.git","clone_url":"https://github.com/dgryski/carbonapi.git","svn_url":"https://github.com/dgryski/carbonapi","homepage":"","size":1022,"stargazers_count":65,"watchers_count":65,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":23,"forks":30,"open_issues":23,"watchers":65,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dgryski/carbonapi/pulls/159"},"html":{"href":"https://github.com/dgryski/carbonapi/pull/159"},"issue":{"href":"https://api.github.com/repos/dgryski/carbonapi/issues/159"},"comments":{"href":"https://api.github.com/repos/dgryski/carbonapi/issues/159/comments"},"review_comments":{"href":"https://api.github.com/repos/dgryski/carbonapi/pulls/159/comments"},"review_comment":{"href":"https://api.github.com/repos/dgryski/carbonapi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dgryski/carbonapi/pulls/159/commits"},"statuses":{"href":"https://api.github.com/repos/dgryski/carbonapi/statuses/d3730ee2eafb3af141d5fcdf1a4d4b4ec1abdf9a"}}}}
{"actor":{"display_login":"nnuss"}}