From f966abcb9ba813d557ddad98d76a775cf1e344d1 Mon Sep 17 00:00:00 2001 From: John Bodley <4567245+john-bodley@users.noreply.github.com> Date: Tue, 10 Apr 2018 18:34:32 -0700 Subject: [PATCH] [logs] Dropping dt column (#4587) --- UPDATING.md | 1 + superset/migrations/versions/30bb17c0dc76_.py | 26 +++++++++++++++++++ superset/models/core.py | 5 ++-- superset/views/core.py | 18 ------------- tests/base_tests.py | 1 - tests/security_tests.py | 1 - 6 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 superset/migrations/versions/30bb17c0dc76_.py diff --git a/UPDATING.md b/UPDATING.md index a5dbb34d1a619..e18409f89d081 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -6,3 +6,4 @@ assists people when migrating to a new version. ## Superset 0.23.0 * [4565](https://github.com/apache/incubator-superset/pull/4565) +* [4587](https://github.com/apache/incubator-superset/pull/4587) diff --git a/superset/migrations/versions/30bb17c0dc76_.py b/superset/migrations/versions/30bb17c0dc76_.py new file mode 100644 index 0000000000000..c68255b0c82e5 --- /dev/null +++ b/superset/migrations/versions/30bb17c0dc76_.py @@ -0,0 +1,26 @@ +"""empty message + +Revision ID: 30bb17c0dc76 +Revises: f231d82b9b26 +Create Date: 2018-04-08 07:34:12.149910 + +""" + +# revision identifiers, used by Alembic. +revision = '30bb17c0dc76' +down_revision = 'f231d82b9b26' + +from datetime import date + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + with op.batch_alter_table('logs') as batch_op: + batch_op.drop_column('dt') + + +def downgrade(): + with op.batch_alter_table('logs') as batch_op: + batch_op.add_column(sa.Column('dt', sa.Date, default=date.today())) diff --git a/superset/models/core.py b/superset/models/core.py index 5ff737e83b555..d82632873ec6b 100644 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals from copy import copy, deepcopy -from datetime import date, datetime +from datetime import datetime import functools import json import logging @@ -20,7 +20,7 @@ import pandas as pd import sqlalchemy as sqla from sqlalchemy import ( - Boolean, Column, create_engine, Date, DateTime, ForeignKey, Integer, + Boolean, Column, create_engine, DateTime, ForeignKey, Integer, MetaData, select, String, Table, Text, ) from sqlalchemy.engine import url @@ -865,7 +865,6 @@ class Log(Model): user = relationship( security_manager.user_model, backref='logs', foreign_keys=[user_id]) dttm = Column(DateTime, default=datetime.utcnow) - dt = Column(Date, default=date.today()) duration_ms = Column(Integer) referrer = Column(String(1024)) diff --git a/superset/views/core.py b/superset/views/core.py index 7eb6d3a069960..6ffa4ee2c77c9 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -1472,24 +1472,6 @@ def checkbox(self, model_view, id_, attr, value): db.session.commit() return json_success('OK') - @api - @has_access_api - @expose('/activity_per_day') - def activity_per_day(self): - """endpoint to power the calendar heatmap on the welcome page""" - Log = models.Log # noqa - qry = ( - db.session - .query( - Log.dt, - sqla.func.count()) - .group_by(Log.dt) - .all() - ) - payload = {str(time.mktime(dt.timetuple())): - ccount for dt, ccount in qry if dt} - return json_success(json.dumps(payload)) - @api @has_access_api @expose('/schemas//') diff --git a/tests/base_tests.py b/tests/base_tests.py index 3cec2157e4159..3c194bfe3a786 100644 --- a/tests/base_tests.py +++ b/tests/base_tests.py @@ -253,7 +253,6 @@ def assert_can_all(view_menu): self.assertIn(('can_add_slices', 'Superset'), gamma_perm_set) self.assertIn(('can_copy_dash', 'Superset'), gamma_perm_set) - self.assertIn(('can_activity_per_day', 'Superset'), gamma_perm_set) self.assertIn(('can_created_dashboards', 'Superset'), gamma_perm_set) self.assertIn(('can_created_slices', 'Superset'), gamma_perm_set) self.assertIn(('can_csv', 'Superset'), gamma_perm_set) diff --git a/tests/security_tests.py b/tests/security_tests.py index 58ec0c77ea1e2..4e1597bc8d73d 100644 --- a/tests/security_tests.py +++ b/tests/security_tests.py @@ -55,7 +55,6 @@ def assert_can_gamma(self, perm_set): self.assertIn(('can_add_slices', 'Superset'), perm_set) self.assertIn(('can_copy_dash', 'Superset'), perm_set) - self.assertIn(('can_activity_per_day', 'Superset'), perm_set) self.assertIn(('can_created_dashboards', 'Superset'), perm_set) self.assertIn(('can_created_slices', 'Superset'), perm_set) self.assertIn(('can_csv', 'Superset'), perm_set)