Skip to content

Commit

Permalink
Revert "#views users for created dashboards on profile page" (#1943)
Browse files Browse the repository at this point in the history
* Revert "#views users for created dashboards on profile page"

* Change the downversion after after-version

* Update models.py
  • Loading branch information
vera-liu authored Jan 11, 2017
1 parent 98e8325 commit 761462e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 84 deletions.
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
4 changes: 2 additions & 2 deletions superset/migrations/versions/1296d28ec131_druid_exports.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""Adds params to the datasource (druid) table
Revision ID: 1296d28ec131
Revises: e46f2d27a08e
Revises: 6414e83d82b7
Create Date: 2016-12-06 17:40:40.389652
"""

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

from alembic import op
import sqlalchemy as sa
Expand Down
64 changes: 0 additions & 64 deletions superset/migrations/versions/1b2c3f7c96f9_.py

This file was deleted.

10 changes: 4 additions & 6 deletions superset/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ class Slice(Model, AuditMixinNullable, ImportMixin):
cache_timeout = Column(Integer)
perm = Column(String(1000))
owners = relationship("User", secondary=slice_user)
views = Column(Integer, default=1)

export_fields = ('slice_name', 'datasource_type', 'datasource_name',
'viz_type', 'params', 'cache_timeout')
Expand Down Expand Up @@ -442,9 +441,9 @@ class Dashboard(Model, AuditMixinNullable, ImportMixin):
slices = relationship(
'Slice', secondary=dashboard_slices, backref='dashboards')
owners = relationship("User", secondary=dashboard_user)

export_fields = ('dashboard_title', 'position_json', 'json_metadata',
'description', 'css', 'slug')
views = Column(Integer, default=1)

def __repr__(self):
return self.dashboard_title
Expand Down Expand Up @@ -2554,8 +2553,8 @@ class Log(Model):
id = Column(Integer, primary_key=True)
action = Column(String(512))
user_id = Column(Integer, ForeignKey('ab_user.id'))
dashboard_id = Column(Integer, ForeignKey('dashboards.id'))
slice_id = Column(Integer, ForeignKey('slices.id'))
dashboard_id = Column(Integer)
slice_id = Column(Integer)
json = Column(Text)
user = relationship('User', backref='logs', foreign_keys=[user_id])
dttm = Column(DateTime, default=datetime.utcnow)
Expand Down Expand Up @@ -2596,8 +2595,7 @@ def wrapper(*args, **kwargs):
datetime.now() - start_dttm).total_seconds() * 1000,
referrer=request.referrer[:1000] if request.referrer else None,
user_id=user_id)
db.session.add(log)
db.session.commit()
db.session.flush()
return value
return wrapper

Expand Down
16 changes: 8 additions & 8 deletions superset/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1444,8 +1444,6 @@ def explore(self, datasource_type, datasource_id):

if slice_id:
slc = db.session.query(models.Slice).filter_by(id=slice_id).first()
slc.views = slc.views + 1
db.session.commit()

error_redirect = '/slicemodelview/list/'
datasource_class = SourceRegistry.sources[datasource_type]
Expand Down Expand Up @@ -1963,7 +1961,10 @@ def created_dashboards(self, user_id):
Dash,
)
.filter(
Dash.created_by_fk == user_id,
sqla.or_(
Dash.created_by_fk == user_id,
Dash.changed_by_fk == user_id,
)
)
.order_by(
Dash.changed_on.desc()
Expand All @@ -1975,7 +1976,6 @@ def created_dashboards(self, user_id):
'title': o.dashboard_title,
'url': o.url,
'dttm': o.changed_on,
'views': o.views,
} for o in qry.all()]
return Response(
json.dumps(payload, default=utils.json_int_dttm_ser),
Expand All @@ -1990,7 +1990,10 @@ def created_slices(self, user_id):
qry = (
db.session.query(Slice)
.filter(
Slice.created_by_fk == user_id,
sqla.or_(
Slice.created_by_fk == user_id,
Slice.changed_by_fk == user_id,
)
)
.order_by(Slice.changed_on.desc())
)
Expand All @@ -1999,7 +2002,6 @@ def created_slices(self, user_id):
'title': o.slice_name,
'url': o.slice_url,
'dttm': o.changed_on,
'views': o.views,
} for o in qry.all()]
return Response(
json.dumps(payload, default=utils.json_int_dttm_ser),
Expand Down Expand Up @@ -2136,8 +2138,6 @@ def dashboard(self, dashboard_id):
qry = qry.filter_by(slug=dashboard_id)

dash = qry.one()
dash.views = dash.views + 1
db.session.commit()
datasources = {slc.datasource for slc in dash.slices}
for datasource in datasources:
if not self.datasource_access(datasource):
Expand Down

0 comments on commit 761462e

Please sign in to comment.