-
Notifications
You must be signed in to change notification settings - Fork 3
Load dashboard on environment setup #112
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
Open
aspedrosa
wants to merge
8
commits into
dev
Choose a base branch
from
imp/load_dashboards
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2659b0e
add initial changes
f2905d4
Make the load of dashboards a one time thing
2619833
Create fixtures for initial data
1a2cf0a
Create a command for generating materialized views
8a806c5
Insert admin credentials through a prompt
628729a
Create Superset url variable to fill tabs url
9f6ca0e
Add --rm so containers to run commands get removed
527f43b
Update docker setup
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,3 @@ | ||
| # custom file created at docker/superset | ||
| docker-init.sh | ||
|
|
||
| # Docker volumes | ||
| volumes/ | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 173 additions & 0 deletions
173
dashboard_viewer/materialized_queries_manager/fixtures/initial_data.json
Large diffs are not rendered by default.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
...ard_viewer/materialized_queries_manager/management/commands/build_materialized_queries.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| from contextlib import closing | ||
|
|
||
| from django.conf import settings | ||
| from django.core.management.base import BaseCommand | ||
| from django.db import connections | ||
| from django.db.utils import ProgrammingError | ||
| from materialized_queries_manager.models import MaterializedQuery | ||
|
|
||
|
|
||
| class Command(BaseCommand): | ||
|
|
||
| help = ( | ||
| "Generates the materialized queries records as materialized views on Postgres" | ||
| ) | ||
|
|
||
| def handle(self, *_, **__): | ||
| with closing(connections["achilles"].cursor()) as cursor: | ||
| for materialized_query in MaterializedQuery.objects.all(): | ||
|
|
||
| cursor.execute( | ||
| "SELECT COUNT(*) FROM pg_matviews WHERE matviewname = %s", | ||
| [materialized_query.name], | ||
| ) | ||
| if cursor.fetchone()[0] > 0: | ||
| self.stdout.write( | ||
| f"Materialized view {materialized_query.name} already exists. Skipping.", | ||
| self.style.WARNING, | ||
| ) | ||
| continue | ||
|
|
||
| try: | ||
| cursor.execute( | ||
| f"CREATE MATERIALIZED VIEW {materialized_query.name} AS {materialized_query.query}" | ||
| ) | ||
|
|
||
| cursor.execute( | ||
| f"GRANT SELECT ON {materialized_query.name} TO {settings.POSTGRES_SUPERSET_USER}" | ||
| ) | ||
| except ProgrammingError as e: | ||
| self.stderr.write( | ||
| f"Invalid sql on query '{materialized_query.name}'. Skipping. You should edit the sql query " | ||
| f"under the admin app and the materialized views will be created. Error: {e}", | ||
| self.style.ERROR, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
161 changes: 161 additions & 0 deletions
161
dashboard_viewer/tabsManager/fixtures/initial_data.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| [ | ||
| { | ||
| "model": "tabsManager.button", | ||
| "pk": 1, | ||
| "fields": { | ||
| "title": "Death", | ||
| "icon": "times", | ||
| "position": 15, | ||
| "visible": true | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.button", | ||
| "pk": 2, | ||
| "fields": { | ||
| "title": "Person", | ||
| "icon": "users", | ||
| "position": 5, | ||
| "visible": true | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.button", | ||
| "pk": 3, | ||
| "fields": { | ||
| "title": "Visit", | ||
| "icon": "calendar-day", | ||
| "position": 12, | ||
| "visible": true | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.button", | ||
| "pk": 4, | ||
| "fields": { | ||
| "title": "General Concepts", | ||
| "icon": "asterisk", | ||
| "position": 16, | ||
| "visible": true | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.button", | ||
| "pk": 5, | ||
| "fields": { | ||
| "title": "Data Domains", | ||
| "icon": "table", | ||
| "position": 19, | ||
| "visible": true | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.button", | ||
| "pk": 6, | ||
| "fields": { | ||
| "title": "General", | ||
| "icon": "asterisk", | ||
| "position": 1, | ||
| "visible": true | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.button", | ||
| "pk": 7, | ||
| "fields": { | ||
| "title": "Population characteristics", | ||
| "icon": "globe-europe", | ||
| "position": 6, | ||
| "visible": true | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.button", | ||
| "pk": 8, | ||
| "fields": { | ||
| "title": "Concepts", | ||
| "icon": "book-medical", | ||
| "position": 16, | ||
| "visible": true | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.button", | ||
| "pk": 9, | ||
| "fields": { | ||
| "title": "Concept Domains", | ||
| "icon": "chart-bar", | ||
| "position": 17, | ||
| "visible": true | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.tabgroup", | ||
| "pk": 1, | ||
| "fields": {} | ||
| }, | ||
| { | ||
| "model": "tabsManager.tab", | ||
| "pk": 1, | ||
| "fields": { | ||
| "url": "https://{SUPERSET_URL}/superset/dashboard/death/?standalone=true", | ||
| "group": null | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.tab", | ||
| "pk": 2, | ||
| "fields": { | ||
| "url": "https://{SUPERSET_URL}/superset/dashboard/person/?standalone=true", | ||
| "group": null | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.tab", | ||
| "pk": 3, | ||
| "fields": { | ||
| "url": "https://{SUPERSET_URL}/superset/dashboard/visit/?standalone=true", | ||
| "group": null | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.tab", | ||
| "pk": 4, | ||
| "fields": { | ||
| "url": "https://{SUPERSET_URL}/superset/dashboard/concepts-general/?standalone=true", | ||
| "group": 1 | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.tab", | ||
| "pk": 5, | ||
| "fields": { | ||
| "url": "https://{SUPERSET_URL}/superset/dashboard/data-domains/?standalone=true", | ||
| "group": null | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.tab", | ||
| "pk": 6, | ||
| "fields": { | ||
| "url": "https://{SUPERSET_URL}/superset/dashboard/general/?standalone=true", | ||
| "group": null | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.tab", | ||
| "pk": 7, | ||
| "fields": { | ||
| "url": "https://{SUPERSET_URL}/superset/dashboard/period/?standalone=true", | ||
| "group": null | ||
| } | ||
| }, | ||
| { | ||
| "model": "tabsManager.tab", | ||
| "pk": 8, | ||
| "fields": { | ||
| "url": "https://{SUPERSET_URL}/superset/dashboard/concepts-domains/?standalone=true", | ||
| "group": 1 | ||
| } | ||
| } | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.