Skip to content

Commit

Permalink
Merge pull request #465 from EverythingMe/fix/time_field_serialize
Browse files Browse the repository at this point in the history
Feature: ability to control series order in charts.
  • Loading branch information
arikfr committed Jun 30, 2015
2 parents d837737 + a9bff90 commit 9cdc2cb
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 29 deletions.
6 changes: 6 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"""
CLI to manage redash.
"""
import json

from flask.ext.script import Manager

from redash import settings, models, __version__
from redash.wsgi import app
from redash.import_export import import_manager
from redash.cli import users, database, data_sources
from redash.monitor import get_status

manager = Manager(app)
manager.add_command("database", database.manager)
Expand All @@ -21,6 +24,9 @@ def version():
"""Displays re:dash version."""
print __version__

@manager.command
def status():
print json.dumps(get_status(), indent=2)

@manager.command
def runworkers():
Expand Down
2 changes: 1 addition & 1 deletion rd_ui/app/scripts/visualizations/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
scope.visualization.options.seriesOptions[s] = {'type': scope.visualization.options.globalSeriesType, 'yAxis': 0};
}
scope.visualization.options.seriesOptions[s].zIndex = scope.visualization.options.seriesOptions[s].zIndex === undefined ? i : scope.visualization.options.seriesOptions[s].zIndex;

scope.visualization.options.seriesOptions[s].index = scope.visualization.options.seriesOptions[s].index === undefined ? i : scope.visualization.options.seriesOptions[s].index;
});
scope.zIndexes = _.range(scope.series.length);
scope.yAxes = [[0, 'left'], [1, 'right']];
Expand Down
9 changes: 9 additions & 0 deletions rd_ui/app/views/visualizations/chart_editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@
class="form-control"></select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3">Index</label>

<div class="col-sm-9">
<select required ng-model="visualization.options.seriesOptions[seriesName].index"
ng-options="o as o for o in zIndexes"
class="form-control"></select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3">y Axis</label>

Expand Down
30 changes: 2 additions & 28 deletions redash/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from redash.cache import headers as cache_headers
from redash.permissions import require_permission
from redash.query_runner import query_runners, validate_configuration
from redash.monitor import get_status


@app.route('/ping', methods=['GET'])
Expand Down Expand Up @@ -98,34 +99,7 @@ def logout():
@auth.required
@require_permission('admin')
def status_api():
status = {}
info = redis_connection.info()
status['redis_used_memory'] = info['used_memory_human']
status['version'] = __version__
status['queries_count'] = models.Query.select().count()
status['query_results_count'] = models.QueryResult.select().count()
status['unused_query_results_count'] = models.QueryResult.unused().count()
status['dashboards_count'] = models.Dashboard.select().count()
status['widgets_count'] = models.Widget.select().count()

status['workers'] = []

manager_status = redis_connection.hgetall('redash:status')
status['manager'] = manager_status
status['manager']['outdated_queries_count'] = len(models.Query.outdated_queries())

queues = {}
for ds in models.DataSource.select():
for queue in (ds.queue_name, ds.scheduled_queue_name):
queues.setdefault(queue, set())
queues[queue].add(ds.name)

status['manager']['queues'] = {}
for queue, sources in queues.iteritems():
status['manager']['queues'][queue] = {
'data_sources': ', '.join(sources),
'size': redis_connection.llen(queue)
}
status = get_status()

return jsonify(status)

Expand Down
33 changes: 33 additions & 0 deletions redash/monitor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from redash import redis_connection, models, __version__

def get_status():
status = {}
info = redis_connection.info()
status['redis_used_memory'] = info['used_memory_human']
status['version'] = __version__
status['queries_count'] = models.Query.select().count()
status['query_results_count'] = models.QueryResult.select().count()
status['unused_query_results_count'] = models.QueryResult.unused().count()
status['dashboards_count'] = models.Dashboard.select().count()
status['widgets_count'] = models.Widget.select().count()

status['workers'] = []

manager_status = redis_connection.hgetall('redash:status')
status['manager'] = manager_status
status['manager']['outdated_queries_count'] = len(models.Query.outdated_queries())

queues = {}
for ds in models.DataSource.select():
for queue in (ds.queue_name, ds.scheduled_queue_name):
queues.setdefault(queue, set())
queues[queue].add(ds.name)

status['manager']['queues'] = {}
for queue, sources in queues.iteritems():
status['manager']['queues'][queue] = {
'data_sources': ', '.join(sources),
'size': redis_connection.llen(queue)
}

return status

0 comments on commit 9cdc2cb

Please sign in to comment.