Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#views users for created dashboards on profile page #1667

Merged
merged 8 commits into from
Jan 7, 2017

Conversation

vera-liu
Copy link
Contributor

@vera-liu vera-liu commented Nov 22, 2016

I'm not sure if this is the standard way to add index. Any suggestions are appreciated.

Done:

  • Added #views as column to dashboards and slices
  • Pre-populates #views from logs table
  • Include # views in CreatedContent component

Note:

  • for postgres users, #views started counting from the time of this PR

@mistercrunch @bkyryliuk

screen shot 2016-12-15 at 5 21 06 pm

@ascott
Copy link

ascott commented Nov 23, 2016

should we add views and users to slices as well? if not i think we should align the favorited columns so the line up vertically.

@ascott
Copy link

ascott commented Nov 29, 2016

not too familiar with sqlalchemy indexes but otherwise LGTM. @mistercrunch @bkyryliuk any comments on the indexing code here?

Copy link
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit worried about how this can introduce lag in loading simple dashbaord or slice lists. How does it perform on production with millions of entries in the logs table?

If we're going to refer to views per dashboard commonly I think we should maintain a counter in the dashboard. That would mean a database migration script to add the field and prepolutate it, and and incrementing the view counter on the dashboard endpoint.

)
.join(Log)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outerjoin

also note that the query may perform better as a join to a subquery on the Log table that aggregates by dashboard id

.order_by(
Dash.changed_on.desc()
)
.group_by(Dash.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure but it seems like this should be .group_by(Dash) or individual fields should be specified in the select and group_by clauses

json = Column(Text)
user = relationship('User', backref='logs', foreign_keys=[user_id])
dttm = Column(DateTime, default=datetime.utcnow)
dt = Column(Date, default=date.today())
views = Index(dashboard_id, user_id, action, dttm)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the common way is more something like this:

    __table_args__ = (
        Index(foo),
        Index(bar),
    )



def upgrade():
op.create_index(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious, was this auto-generated or did you copy/paste it from some place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is auto-generated and modified

@vera-liu
Copy link
Contributor Author

I reverted the original query appraoch, added the views column to dashboards and slices, pre populated them with Log data in the migration file.

@vera-liu vera-liu force-pushed the vliu_dashboard_view branch from 54361dc to a4aa9fe Compare December 16, 2016 01:32
@vera-liu vera-liu changed the title #views and #distinct users for created dashboards on profile page #views users for created dashboards on profile page Dec 16, 2016
@mistercrunch
Copy link
Member

LGMT

@vera-liu vera-liu force-pushed the vliu_dashboard_view branch 2 times, most recently from 868c2d8 to f7b8271 Compare December 17, 2016 04:27
@vera-liu vera-liu force-pushed the vliu_dashboard_view branch from 3f8a115 to 795dc5b Compare January 3, 2017 19:28
@vera-liu vera-liu merged commit cec4cf0 into apache:master Jan 7, 2017
SalehHindi pushed a commit to SalehHindi/superset that referenced this pull request Jun 9, 2017
* Add #views and #distinct users to created dashboard on profile page

* Added index on logs to speed up query

* Added #views and #users for slice table

* Add a views column to dashboards and slices, prepopulate
them with Log data

* Remove index on Log model

* Remove unused index

* Update 1b2c3f7c96f9_.py

fix multiple heads

* Exclude postgres in prepopulating views column
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.15.2 labels Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.15.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants