Commit dc2cf095 authored by 20after4's avatar 20after4
Browse files

Move charts to separate yaml files and queries to separate sql files

parent 3ac87d43
title: Workboard Progression
db: metrics
requires: [ project, -task_id ]
tab: columns
tab: charts
order: 2
query: workboard_progression
type: vega
display:
......@@ -26,7 +27,7 @@ display:
orient: right
color:
field: old_new
title: old -> new
title: Column old->new
type: nominal
legend:
direction: horizontal
......@@ -57,7 +58,9 @@ display:
value: null
facet:
field: month
title: Month (ending date)
title: Month, Year
type: temporal
columns: 3
margin: 5
spacing: 4
margin: 2
timeUnit: monthyear
\ No newline at end of file
{
"date": {
"start": "{{params['date_start']}}",
"end": "{{params['date_end']}}"
},
"cycle_time": { "mean": "{{mean_cycle_time }}", "median": "{{median_cycle_time}}" },
"lead_time": { "mean": "{{mean_lead_time}}", "median": "{{median_lead_time}}" },
"columns": [ "id", "url", "points", "owner", "date_created", "date_modified", "start_of_work", "state", "title", "date_ended", "lead", "duration", "duration_proportion_of_mean", "wait_time", "cycle_time", "mean_cycle_time"],
"rows": [
{% for task in tasks %}
{%- set data = task['data']%}{%- if loop.index > 1 %},{% endif %}
{
"id":"T{{task['id']}}",
"url": "https://phabricator.wikimedia.org/T{{task['id']}}",
"points": "{{data['points'] or 0}}",
"owner": "{{task['data']['owner']}}",
"date_created": "{{tsdate(data.get('dateCreated', 0))}}",
"date_modified": "{{tsdate(data.get('dateModified', 0))}}",
"start_of_work": "{{task['start'].date()}}",
{%- if task['state'] %}"state":"{{task['state']}}",{% endif %}
"title": "{{task['data']['name']|urlencode}}"
{%- if task['end'] %} ,
"date_ended": "{{task['end'].date()}}",
"lead": {{task['lead']}},
"duration": {{task['duration'].days}},
"wait_time": {{round(task['lead'] - task['duration'].days, 1)}},
"cycle_time": {{task['duration'].days}},
"mean_cycle": {{mean_cycle_time}}
{% endif %}
}{% endfor %}
]
}
\ No newline at end of file
......@@ -148,7 +148,7 @@ async def init_context(datasette:Datasette, db:Database, request:Request, contex
context['int'] = int
context['round'] = round
tids = ", ".join([str(t) for t in included_tasks.keys()])
details = await db.execute(f'select * from Task where id in({tids})')
details = await db.execute(f'select t.*, p.name as owner from Task t join phobjects p on t.ownerPHID=p.phid where t.id in({tids})')
for row in details:
id = row['id']
policy = json.loads(row['policy'])
......
{% extends "view.html" %}
{% block title %}Data³ - Phabricator Metrics{%endblock%}
{% block extra_head %}
<!--<script type='module' src='{{base_url}}static/DashboardApp.js'></script>-->
<script>
......@@ -18,6 +18,8 @@ window['BASE_URL'] ='{{base_url}}';
<static-data-set id='ds-project_tree'
url="{{base_url}}metrics/project_tree.json?_shape=objects&_size=max&_ttl=86400">
</static-data-set>
<data-set db='metrics', id='ds-cycletime' params='project,date_start,date_end' url="{{base_url}}-/ddd/cycletime.json?">
</data-set>
{% for id,query in queries.items() %}
<data-set db='metrics' id='ds-{{id}}' params='{{query.params|join(",") }}' url='{{base_url}}metrics/{{id}}.json?_shape=objects'>{{query.sql}}</data-set>
{% endfor %}
......@@ -46,10 +48,10 @@ window['BASE_URL'] ='{{base_url}}';
<nav-tabs id='tabs' selected='columns'>
{% for tabid, tab in layout.tabs.items() %}
<tab-item id='{{tabid}}' {%if tabid=='projects'%}value=1 class='active'{%endif%} label='{{tab.label}}'>
<tab-item id='{{tabid}}' {%if tabid=='charts'%}value=1 class='active'{%endif%} label='{{tab.label}}'>
{% for id, chart in tab.charts.items() %}
{% if chart.type=='vega' %}
<vega-chart data-source='ds-{{chart.query}}' id='vega-chart-{{id}}' title="{{chart.title}}">
<vega-chart data-source='ds-{{chart.query}}' id='vega-chart-{{id}}' title="{{chart.title}}"{%if chart.order%} order="{{chart.order}}"{%endif%}>
<script type='template' id='vega-spec-{{id}}'>{{chart.display|tojson}}</script>
</vega-chart>
{%endif%}
......@@ -62,5 +64,5 @@ window['BASE_URL'] ='{{base_url}}';
</nav-tabs>
</dashboard-app>
<modal-dialog>Test...</modal-dialog>
<task-dialog id='task-modal'></task-dialog>
{% endblock %}
\ No newline at end of file
......@@ -58,6 +58,8 @@ class DashboardLayout(object):
for chartid, chart in self.config['charts'].items():
tabid = chart.get('tab', 'default')
if tabid == 'hidden':
continue
tab = self.tab(tabid)
tab.charts[chartid] = chart
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment