mirror of
https://github.com/apache/superset.git
synced 2024-09-12 16:49:40 -04:00
Logging more
This commit is contained in:
parent
460f6cbed5
commit
b1f88a53ad
24
panoramix/migrations/versions/430039611635_log_more.py
Normal file
24
panoramix/migrations/versions/430039611635_log_more.py
Normal file
@ -0,0 +1,24 @@
|
||||
"""log more
|
||||
|
||||
Revision ID: 430039611635
|
||||
Revises: d827694c7555
|
||||
Create Date: 2016-02-10 08:47:28.950891
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '430039611635'
|
||||
down_revision = 'd827694c7555'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
def upgrade():
|
||||
op.add_column('logs', sa.Column('dashboard_id', sa.Integer(), nullable=True))
|
||||
op.add_column('logs', sa.Column('slice_id', sa.Integer(), nullable=True))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('logs', 'slice_id')
|
||||
op.drop_column('logs', 'dashboard_id')
|
@ -1045,6 +1045,9 @@ 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)
|
||||
slice_id = Column(Integer)
|
||||
user_id = Column(Integer, ForeignKey('ab_user.id'))
|
||||
json = Column(Text)
|
||||
user = relationship('User', backref='logs', foreign_keys=[user_id])
|
||||
dttm = Column(DateTime, default=func.now())
|
||||
|
@ -187,14 +187,16 @@ def log_this(f):
|
||||
if g.user:
|
||||
user_id = g.user.id
|
||||
from panoramix import models
|
||||
d = request.args.to_dict()
|
||||
d.update(kwargs)
|
||||
log = models.Log(
|
||||
action=f.__name__,
|
||||
json=json.dumps(request.args.to_dict()),
|
||||
json=json.dumps(d),
|
||||
dashboard_id=d.get('dashboard_id'),
|
||||
slice_id=d.get('slice_id'),
|
||||
user_id=user_id)
|
||||
|
||||
db.session.add(log)
|
||||
db.session.commit()
|
||||
|
||||
return f(*args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
|
@ -534,15 +534,15 @@ class Panoramix(BaseView):
|
||||
mimetype="application/json")
|
||||
|
||||
@has_access
|
||||
@expose("/dashboard/<identifier>/")
|
||||
@expose("/dashboard/<dashboard_id>/")
|
||||
@utils.log_this
|
||||
def dashboard(self, identifier):
|
||||
def dashboard(self, dashboard_id):
|
||||
session = db.session()
|
||||
qry = session.query(models.Dashboard)
|
||||
if identifier.isdigit():
|
||||
qry = qry.filter_by(id=int(identifier))
|
||||
if dashboard_id.isdigit():
|
||||
qry = qry.filter_by(id=int(dashboard_id))
|
||||
else:
|
||||
qry = qry.filter_by(slug=identifier)
|
||||
qry = qry.filter_by(slug=dashboard_id)
|
||||
|
||||
templates = session.query(models.CssTemplate).all()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user