{"id":22959558,"url":"https://github.com/probe-lab/ashby","last_synced_at":"2025-04-02T02:25:29.192Z","repository":{"id":163562697,"uuid":"636233908","full_name":"probe-lab/ashby","owner":"probe-lab","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-28T13:06:16.000Z","size":80,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T14:22:50.141Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/probe-lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-04T11:55:38.000Z","updated_at":"2025-03-28T13:06:18.000Z","dependencies_parsed_at":"2023-11-07T12:27:31.617Z","dependency_job_id":"ca856ad1-09cf-440f-8d09-c8cfea93080d","html_url":"https://github.com/probe-lab/ashby","commit_stats":null,"previous_names":["probe-lab/ashby","plprobelab/ashby"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probe-lab%2Fashby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probe-lab%2Fashby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probe-lab%2Fashby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probe-lab%2Fashby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/probe-lab","download_url":"https://codeload.github.com/probe-lab/ashby/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246742533,"owners_count":20826353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-14T18:19:15.381Z","updated_at":"2025-04-02T02:25:29.166Z","avatar_url":"https://github.com/probe-lab.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ashby\n\n`ashby` produces plots for the [ProbeLab CMI website](https://github.com/probe-lab/website)\n\nCurrently it only supports an interactive mode but the goal is to run it as a daemon and for it to \nproduce automatically plots on a schedule.\n\n## Getting Started\n\nRun `go build` in the `/cmd/ashby` folder.\n\nIf you're just trying the static demo plots then you can use:\n\n\t./ashby plot --preview ../../plots/demo-static-bar-grouped.json\n\nIt outputs the JSON that defines the plot and can be passed to the plotly JavaScript library.\n\n`--preview` makes ashby launch the plot as a preview in your browser\n\nIf you want to try a postgres demo plot then you need to specify the postgres datasource with the `-s` option:\n\n\t-s name=postgres://username:password@hostname:5432/database_name\n\nFor the demos the name is `pgnebula`, so you should run:\n\n\t./ashby plot --preview -s pgnebula=postgres://username:password@hostname/database_name?sslmode=prefer ../../plots/demo-pg-agents-bar.json\n\n(with the database details filled in, of course!)\n\n\n## Plot Specifications\n\nPlots are defined in JSON. Some samples are in the `plots` folder at the root of this repo.\n\nThe specification format is in flux but currently there are three sections to each plot specification.\n\n - `datasets` - this specifies a list of named datasets that provide source data for the plots. Each has a source and query. Support for query parameters is on the TODO list. A dataset is essentially a list of named fields and their data values, usually a tabular structure.\n - `series` - this specifies a list of series that are to be plotted. Each series specifies the field to use for labelling the points in the series and a field for the values. Each series will be plotted onto the final chart.\n - `layout` - this defines the layout for the plot. Currently it's just the same as the plotly layout definition but ideally we will support only a useful subset to avoid coupling too tightly to a single plotting library.\n\n\nAn example plot spec:\n\n```json\n\t{\n\t  \"datasets\": [\n\t    {\n\t      \"name\":\"main\",\n\t      \"source\":\"demo\",\n\t      \"query\":\"populations\"\n\t    }\n\t  ],\n\n\t  \"series\": [\n\t    {\n\t      \"type\": \"bar\",\n\t      \"name\": \"population\",\n\t      \"dataset\": \"main\",\n\t      \"labels\": \"creature\",\n\t      \"values\": \"month1\"\n\t    }\n\t  ],\n\n\t  \"layout\":{\n\t    \"title\":{\n\t      \"text\":\"Demo: Bar\"\n\t    }\n\t  }\n\t}\n```\n\n## Templating\n\nPlot definitions may use Go's templating capabilities. \nPlot definition files are parsed and executed as a Go template before parsing into the final plot definition model.\n\nThe following functions are available:\n\n - All [Sprig](https://masterminds.github.io/sprig/) functions \n - `timestamptz` - format a time as a Postgresql `timestamptz`  (for example: `'2023-03-13 00:00:00 Z'::timestampz`)\n - `timestamp` - format a time as a Postgresql `timestamp`  (for example: `'2023-03-13 00:00:00'::timestamp`)\n - `simpledate` - format a time in a simple, human readable format (for example: `13 Mar 2023`)\n - `isodate` - format a time as RFC3339 (for example: `2023-03-13T00:00:00Z`)\n - `dayModify` - a version of [sprig's dateModify](https://masterminds.github.io/sprig/date.html#datemodify-mustdatemodify) that accepts a number of days\n - `weekModify` - a version of [sprig's dateModify](https://masterminds.github.io/sprig/date.html#datemodify-mustdatemodify) that accepts a number of weeks\n - `monthModify` - a version of [sprig's dateModify](https://masterminds.github.io/sprig/date.html#datemodify-mustdatemodify) that accepts a number of months\n\nThe following data variables are available:\n\n - `.Now` - the basis time for the plot, this might be the current date or a date in the past if the plot is being regenerated. This should be used as the basis for all date calculations\n - `.StartOfHour` - the basis time truncated to the hour, so that minutes and seconds are removed\n - `.StartOfDay` - the basis time truncated to the day, so that hours, minutes and seconds are removed\n - `.StartOfWeek` - the basis time truncated to the start of the week containing the basis time\n\nThe following are useful when formatting dates that are immediately before the start of the period.\nThey are not really suitable for use as the end of a range in a query.\n\n - `.EndOfPreviousHour` - one nanosecond before `.StartOfHour`\n - `.EndOfPreviousHour` - one nanosecond before `.StartOfDay`\n - `.EndOfPreviousHour` - one nanosecond before `.StartOfWeek`\n\n\n### Templating Examples\n\nA one week range up to the week including the basis time, in Postgresql:\n\n\ttstzrange({{ .StartOfWeek | timestamptz }}-'1 week'::interval, {{ .StartOfWeek | timestamptz }})\n\nLimiting a Postgresql query to 30 days before the basis time:\n\n\tand m1.created_at \u003e= {{ .StartOfDay | timestamptz }}-'30 day'::interval\n\tand m1.created_at \u003c {{ .StartOfDay | timestamptz }}\n\nUsing `.EndOfPreviousDay` to construct a title for a plot:\n\n\t30 days up to {{ .EndOfPreviousDay | simpledate }}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprobe-lab%2Fashby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprobe-lab%2Fashby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprobe-lab%2Fashby/lists"}