Skip to content

Commit

Permalink
Fixing some translation related error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jun 10, 2016
1 parent 8d7c9b6 commit 59ab576
Show file tree
Hide file tree
Showing 15 changed files with 201 additions and 161 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ env:
global:
- TRAVIS_CACHE=$HOME/.travis_cache/
matrix:
- TOX_ENV=py27-mysql
#- TOX_ENV=py27-mysql
- TOX_ENV=py27-sqlite
- TOX_ENV=py27-postgres
#- TOX_ENV=py27-postgres
- TOX_ENV=py34-sqlite
- TOX_ENV=py34-mysql
- TOX_ENV=javascript
before_install:
- npm install -g npm@'>=2.7.1'
before_script:
- mysql -e 'drop database if exists airflow; create database airflow' -u root
- psql -c 'create database airflow;' -U postgres
- mysql -e 'drop database if exists caravel; create database caravel DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci' -u root
- psql -c 'create database caravel;' -U postgres
- export PATH=${PATH}:/tmp/hive/bin
install:
- pip install --upgrade pip
Expand Down
174 changes: 87 additions & 87 deletions caravel/assets/visualizations/nvd3_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ function nvd3Vis(slice) {
var colorKey = 'key';

var render = function () {
$.getJSON(slice.jsonEndpoint(), function (payload) {
d3.json(slice.jsonEndpoint(), function (error, payload) {
slice.container.html('');
if (error) {
slice.error(error.responseText);
return '';
}
var fd = payload.form_data;
var viz_type = fd.viz_type;
var f = d3.format('.3s');
slice.container.html('');

nv.addGraph(function () {
switch (viz_type) {
case 'line':
if (fd.show_brush) {
chart = nv.models.lineWithFocusChart();
chart.lines2.xScale(d3.time.scale.utc());
chart
.x2Axis
chart.x2Axis
.showMaxMin(fd.x_axis_showminmax)
.staggerLabels(false);
} else {
Expand Down Expand Up @@ -133,103 +136,100 @@ function nvd3Vis(slice) {

default:
throw new Error("Unrecognized visualization for nvd3" + viz_type);
}
}

if ("showLegend" in chart && typeof fd.show_legend !== 'undefined') {
chart.showLegend(fd.show_legend);
}
if ("showLegend" in chart && typeof fd.show_legend !== 'undefined') {
chart.showLegend(fd.show_legend);
}

var height = slice.height();
height -= 15; // accounting for the staggered xAxis
var height = slice.height();
height -= 15; // accounting for the staggered xAxis

chart.height(height);
slice.container.css('height', height + 'px');
chart.height(height);
slice.container.css('height', height + 'px');

if ((viz_type === "line" || viz_type === "area") && fd.rich_tooltip) {
chart.useInteractiveGuideline(true);
}
if (fd.y_axis_zero) {
chart.forceY([0]);
} else if (fd.y_log_scale) {
chart.yScale(d3.scale.log());
}
if (fd.x_log_scale) {
chart.xScale(d3.scale.log());
}
var xAxisFormatter = null;
if (viz_type === 'bubble') {
xAxisFormatter = d3.format('.3s');
} else if (fd.x_axis_format === 'smart_date') {
xAxisFormatter = px.formatDate;
chart.xAxis.tickFormat(xAxisFormatter);
} else if (fd.x_axis_format !== undefined) {
xAxisFormatter = px.timeFormatFactory(fd.x_axis_format);
chart.xAxis.tickFormat(xAxisFormatter);
}
if ((viz_type === "line" || viz_type === "area") && fd.rich_tooltip) {
chart.useInteractiveGuideline(true);
}
if (fd.y_axis_zero) {
chart.forceY([0]);
} else if (fd.y_log_scale) {
chart.yScale(d3.scale.log());
}
if (fd.x_log_scale) {
chart.xScale(d3.scale.log());
}
var xAxisFormatter = null;
if (viz_type === 'bubble') {
xAxisFormatter = d3.format('.3s');
} else if (fd.x_axis_format === 'smart_date') {
xAxisFormatter = px.formatDate;
chart.xAxis.tickFormat(xAxisFormatter);
} else if (fd.x_axis_format !== undefined) {
xAxisFormatter = px.timeFormatFactory(fd.x_axis_format);
chart.xAxis.tickFormat(xAxisFormatter);
}

if (chart.hasOwnProperty("x2Axis")) {
chart.x2Axis.tickFormat(xAxisFormatter);
height += 30;
}
if (chart.hasOwnProperty("x2Axis")) {
chart.x2Axis.tickFormat(xAxisFormatter);
height += 30;
}

if (viz_type === 'bubble') {
chart.xAxis.tickFormat(d3.format('.3s'));
} else if (fd.x_axis_format === 'smart_date') {
chart.xAxis.tickFormat(px.formatDate);
} else if (fd.x_axis_format !== undefined) {
chart.xAxis.tickFormat(px.timeFormatFactory(fd.x_axis_format));
}
if (chart.yAxis !== undefined) {
chart.yAxis.tickFormat(d3.format('.3s'));
}
if (viz_type === 'bubble') {
chart.xAxis.tickFormat(d3.format('.3s'));
} else if (fd.x_axis_format === 'smart_date') {
chart.xAxis.tickFormat(px.formatDate);
} else if (fd.x_axis_format !== undefined) {
chart.xAxis.tickFormat(px.timeFormatFactory(fd.x_axis_format));
}
if (chart.yAxis !== undefined) {
chart.yAxis.tickFormat(d3.format('.3s'));
}

if (fd.contribution || fd.num_period_compare || viz_type === 'compare') {
chart.yAxis.tickFormat(d3.format('.3p'));
if (chart.y2Axis !== undefined) {
chart.y2Axis.tickFormat(d3.format('.3p'));
if (fd.contribution || fd.num_period_compare || viz_type === 'compare') {
chart.yAxis.tickFormat(d3.format('.3p'));
if (chart.y2Axis !== undefined) {
chart.y2Axis.tickFormat(d3.format('.3p'));
}
} else if (fd.y_axis_format) {
chart.yAxis.tickFormat(d3.format(fd.y_axis_format));

if (chart.y2Axis !== undefined) {
chart.y2Axis.tickFormat(d3.format(fd.y_axis_format));
}
}
} else if (fd.y_axis_format) {
chart.yAxis.tickFormat(d3.format(fd.y_axis_format));
chart.color(function (d, i) {
return px.color.category21(d[colorKey]);
});

if (chart.y2Axis !== undefined) {
chart.y2Axis.tickFormat(d3.format(fd.y_axis_format));
var svg = d3.select(slice.selector).select("svg");
if (svg.empty()) {
svg = d3.select(slice.selector).append("svg");
}
}
chart.color(function (d, i) {
return px.color.category21(d[colorKey]);
});

var svg = d3.select(slice.selector).select("svg");
if (svg.empty()) {
svg = d3.select(slice.selector).append("svg");
}
svg
.datum(payload.data)
.transition().duration(500)
.attr('height', height)
.call(chart);

svg
.datum(payload.data)
.transition().duration(500)
.attr('height', height)
.call(chart);
return chart;
});

return chart;
slice.done(payload);
});

slice.done(payload);
})
.fail(function (xhr) {
slice.error(xhr.responseText);
});
};

var update = function () {
if (chart && chart.update) {
chart.update();
}
};

return {
render: render,
resize: update
};
};

var update = function () {
if (chart && chart.update) {
chart.update();
}
};

return {
render: render,
resize: update
};
}

module.exports = nvd3Vis;
10 changes: 7 additions & 3 deletions caravel/bin/caravel
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,20 @@ def init():
"""Inits the Caravel application"""
utils.init(caravel)

@manager.command
def version():
@manager.option(
'-v', '--verbose', action='store_true',
help="Show extra information")
def version(verbose):
"""Prints the current version number"""
s = (
"\n{boat}\n\n"
"-----------------------\n"
"Caravel {version}\n"
"-----------------------\n").format(
"-----------------------").format(
boat=ascii_art.boat, version=caravel.VERSION)
print(s)
if verbose:
print("[DB] : " + "{}".format(db.engine))

@manager.option(
'-t', '--load-test-data', action='store_true',
Expand Down
5 changes: 0 additions & 5 deletions caravel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
# SQLALCHEMY_DATABASE_URI = 'mysql://myapp@localhost/myapp'
# SQLALCHEMY_DATABASE_URI = 'postgresql://root:password@localhost/myapp'

# Allowing SQLALCHEMY_DATABASE_URI to be defined as an env var for
# continuous integration
if 'CARAVEL__SQLALCHEMY_DATABASE_URI' in os.environ:
SQLALCHEMY_DATABASE_URI = os.environ.get('CARAVEL__SQLALCHEMY_DATABASE_URI')

# Flask-WTF flag for CSRF
CSRF_ENABLED = True

Expand Down
2 changes: 1 addition & 1 deletion caravel/migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from logging.config import fileConfig

from alembic import context
from flask.ext.appbuilder import Base
from flask_appbuilder import Base
from sqlalchemy import engine_from_config, pool

# this is the Alembic Config object, which provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,41 @@
down_revision = '956a063c52b3'

from alembic import op
import sqlalchemy as sa
from caravel import db, models
from caravel.utils import generic_find_constraint_name
import logging

naming_convention = {
"fk":
"fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
}


def find_constraint_name(upgrade=True):
cols = {'column_name'} if upgrade else {'datasource_name'}
return generic_find_constraint_name(table='columns', columns=cols, referenced='datasources')
return generic_find_constraint_name(
table='columns', columns=cols, referenced='datasources', db=db)


def upgrade():
constraint = find_constraint_name() or 'fk_columns_column_name_datasources'
with op.batch_alter_table("columns",
naming_convention=naming_convention) as batch_op:
batch_op.drop_constraint(constraint, type_="foreignkey")
batch_op.create_foreign_key('fk_columns_datasource_name_datasources', 'datasources', ['datasource_name'], ['datasource_name'])
try:
constraint = find_constraint_name() or 'fk_columns_column_name_datasources'
with op.batch_alter_table("columns",
naming_convention=naming_convention) as batch_op:
batch_op.drop_constraint(constraint, type_="foreignkey")
batch_op.create_foreign_key(
'fk_columns_datasource_name_datasources',
'datasources',
['datasource_name'], ['datasource_name'])
except:
logging.warning(
"Could not find or drop constraint on `columns`")

def downgrade():
constraint = find_constraint_name(False) or 'fk_columns_datasource_name_datasources'
with op.batch_alter_table("columns",
with op.batch_alter_table("columns",
naming_convention=naming_convention) as batch_op:
batch_op.drop_constraint(constraint, type_="foreignkey")
batch_op.create_foreign_key('fk_columns_column_name_datasources', 'datasources', ['column_name'], ['datasource_name'])
batch_op.create_foreign_key(
'fk_columns_column_name_datasources',
'datasources',
['column_name'], ['datasource_name'])
3 changes: 1 addition & 2 deletions caravel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,6 @@ def query( # sqla
qry.compile(
engine, compile_kwargs={"literal_binds": True},),
)
print(sql)
df = pd.read_sql_query(
sql=sql,
con=engine
Expand Down Expand Up @@ -1040,7 +1039,7 @@ def generate_metrics(self):
@classmethod
def sync_to_db(cls, name, cluster):
"""Fetches metadata for that datasource and merges the Caravel db"""
print("Syncing Druid datasource [{}]".format(name))
logging.info("Syncing Druid datasource [{}]".format(name))
session = get_session()
datasource = session.query(cls).filter_by(datasource_name=name).first()
if not datasource:
Expand Down
Loading

0 comments on commit 59ab576

Please sign in to comment.