Skip to content

Commit

Permalink
Merge branch 'master' into vliu_dualaxis_bug
Browse files Browse the repository at this point in the history
  • Loading branch information
vera-liu committed Jan 11, 2017
2 parents 3663bac + 761462e commit e76f10f
Show file tree
Hide file tree
Showing 11 changed files with 706 additions and 549 deletions.
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Follow these few simple steps to install Superset.::
# Install superset
pip install superset

# Create an admin user
# Create an admin user (you will be prompted to set username, first and last name before setting a password)
fabmanager create-admin --app superset

# Initialize the database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ class CreatedContent extends React.PureComponent {
renderSliceTable() {
const mutator = (data) => data.map(slice => ({
slice: <a href={slice.url}>{slice.title}</a>,
views: slice.views,
favorited: moment.utc(slice.dttm).fromNow(),
_favorited: slice.dttm,
}));
return (
<TableLoader
dataEndpoint={`/superset/created_slices/${this.props.user.userId}/`}
className="table table-condensed"
columns={['slice', 'favorited', 'views']}
columns={['slice', 'favorited']}
mutator={mutator}
noDataText="No slices"
sortable
Expand All @@ -37,7 +36,6 @@ class CreatedContent extends React.PureComponent {
renderDashboardTable() {
const mutator = (data) => data.map(dash => ({
dashboard: <a href={dash.url}>{dash.title}</a>,
views: dash.views,
favorited: moment.utc(dash.dttm).fromNow(),
_favorited: dash.dttm,
}));
Expand All @@ -47,7 +45,7 @@ class CreatedContent extends React.PureComponent {
mutator={mutator}
dataEndpoint={`/superset/created_dashboards/${this.props.user.userId}/`}
noDataText="No dashboards"
columns={['dashboard', 'favorited', 'views']}
columns={['dashboard', 'favorited']}
sortable
/>
);
Expand Down
2 changes: 1 addition & 1 deletion superset/assets/stylesheets/superset.css
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ div.widget .chart-header a {
}

div.widget .slice_container {
overflow: auto;
overflow: hidden;
}

.navbar .alert {
Expand Down
74 changes: 74 additions & 0 deletions superset/import_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import logging
from sqlalchemy.orm.session import make_transient


def import_datasource(
session,
i_datasource,
lookup_database,
lookup_datasource,
import_time):
"""Imports the datasource from the object to the database.
Metrics and columns and datasource will be overrided if exists.
This function can be used to import/export dashboards between multiple
superset instances. Audit metadata isn't copies over.
"""
make_transient(i_datasource)
logging.info('Started import of the datasource: {}'.format(
i_datasource.to_json()))

i_datasource.id = None
i_datasource.database_id = lookup_database(i_datasource).id
i_datasource.alter_params(import_time=import_time)

# override the datasource
datasource = lookup_datasource(i_datasource)

if datasource:
datasource.override(i_datasource)
session.flush()
else:
datasource = i_datasource.copy()
session.add(datasource)
session.flush()

for m in i_datasource.metrics:
new_m = m.copy()
new_m.table_id = datasource.id
logging.info('Importing metric {} from the datasource: {}'.format(
new_m.to_json(), i_datasource.full_name))
imported_m = i_datasource.metric_cls.import_obj(new_m)
if (imported_m.metric_name not in
[m.metric_name for m in datasource.metrics]):
datasource.metrics.append(imported_m)

for c in i_datasource.columns:
new_c = c.copy()
new_c.table_id = datasource.id
logging.info('Importing column {} from the datasource: {}'.format(
new_c.to_json(), i_datasource.full_name))
imported_c = i_datasource.column_cls.import_obj(new_c)
if (imported_c.column_name not in
[c.column_name for c in datasource.columns]):
datasource.columns.append(imported_c)
session.flush()
return datasource.id


def import_simple_obj(session, i_obj, lookup_obj):
make_transient(i_obj)
i_obj.id = None
i_obj.table = None

# find if the column was already imported
existing_column = lookup_obj(i_obj)
i_obj.table = None
if existing_column:
existing_column.override(i_obj)
session.flush()
return existing_column

session.add(i_obj)
session.flush()
return i_obj
22 changes: 22 additions & 0 deletions superset/migrations/versions/1296d28ec131_druid_exports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Adds params to the datasource (druid) table
Revision ID: 1296d28ec131
Revises: 6414e83d82b7
Create Date: 2016-12-06 17:40:40.389652
"""

# revision identifiers, used by Alembic.
revision = '1296d28ec131'
down_revision = '6414e83d82b7'

from alembic import op
import sqlalchemy as sa


def upgrade():
op.add_column('datasources', sa.Column('params', sa.String(length=1000), nullable=True))


def downgrade():
op.drop_column('datasources', 'params')
64 changes: 0 additions & 64 deletions superset/migrations/versions/1b2c3f7c96f9_.py

This file was deleted.

0 comments on commit e76f10f

Please sign in to comment.