Skip to content

Commit 68829ff

Browse files
authored
exclude known views and enforce naming (#693)
1 parent 6d28b74 commit 68829ff

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

cid/export.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def export_analysis(qs, athena):
123123
if dataset_name in athena._resources.get('datasets'):
124124
resources_datasets.append(dataset_name)
125125
if not get_parameters().get('export-known-datasets'):
126-
cid_print(f' DataSet <BOLD>{dataset_name}<END> is in resources. Skiping.')
126+
cid_print(f' DataSet <BOLD>{dataset_name}<END> is in resources. Skipping.')
127127
continue
128128

129129
dataset_data = {
@@ -145,7 +145,10 @@ def export_analysis(qs, athena):
145145
athena_source = value['RelationalTable']['Name']
146146
views_name = athena_source.split('.')[-1]
147147
dependency_views.append(views_name)
148-
all_views.append(views_name)
148+
if views_name in athena._resources.get('views') and not get_parameters().get('export-known-datasets'):
149+
cid_print(f' Athena view <BOLD>{views_name}<END> is in resources. Skipping')
150+
else:
151+
all_views.append(views_name)
149152
elif 'CustomSql' in value and 'DataSourceArn' in value['CustomSql']:
150153
logger.debug(f"Dataset {dataset.raw['DataSetId']} looks like CustomSql athena dataset")
151154
value['CustomSql']['DataSourceArn'] = '${athena_datasource_arn}'
@@ -250,9 +253,13 @@ def export_analysis(qs, athena):
250253
logger.debug('Building dashboard resource')
251254
dashboard_id = get_parameter(
252255
'dashboard-id',
253-
message='dashboard id (will be used in url of dashboard)',
254-
default=escape_id(analysis['Name'].lower())
256+
message='dashboard id (will be used in dashboard URL. Use lowercase, hyphens(not underscores) and make it short but understandable for humans)',
257+
default=escape_id(analysis['Name'].lower().replace(' ', '-').replace('_', '-'))
255258
)
259+
new_dashboard_id = dashboard_id.lower().replace(' ', '-').replace('_', '-')
260+
if dashboard_id != new_dashboard_id:
261+
cid_print('Best practices enforced: {dashboard_id} -> {new_dashboard_id}')
262+
dashboard_id = new_dashboard_id
256263

257264
dashboard_resource = {}
258265
dashboard_resource['dependsOn'] = {
@@ -272,8 +279,8 @@ def export_analysis(qs, athena):
272279
'dashboard-export-method',
273280
message='Please choose export method',
274281
choices={
282+
'[template] Generate a QuickSight Template in the current account (Recommended)': 'template',
275283
'[definition] Save QuickSight Dashboard Definition in the file': 'definition',
276-
'[template] Generate a QuickSight Template in the current account': 'template',
277284
},
278285
)
279286
if dashboard_export_method == 'template':

0 commit comments

Comments
 (0)