8000 added comments to help users understand how to use the sample python … · prnka11/server-client-python@17921d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 17921d4

Browse files
author
bzhang
committed
added comments to help users understand how to use the sample python script to update/check on materialized views settings
1 parent 699a982 commit 17921d4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

samples/materialize_workbooks.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,36 @@ def main():
4444
print("Use '--type <content type> --mode <enable/disable>' to update materialized views settings.")
4545
return
4646

47+
# enable/disable materialized views for site
4748
if args.type == 'site':
4849
if not update_site(args, enable_materialized_views, password, site_content_url):
4950
return
5051

52+
# enable/disable materialized views for workbook
53+
# works only when the site the workbooks belong to are enabled too
5154
elif args.type == 'workbook':
5255
if not update_workbook(args, enable_materialized_views, password, site_content_url):
5356
return
5457

58+
# enable/disable materialized views for project by project name
59+
# will show possible projects when project name is not unique
5560
elif args.type == 'project_name':
5661
if not update_project_by_name(args, enable_materialized_views, password, site_content_url):
5762
return
5863

64+
# enable/disable materialized views for proejct by project path, for example: project1/project2
5965
elif args.type == 'project_path':
6066
if not update_project_by_path(args, enable_materialized_views, password, site_content_url):
6167
return
6268

69+
# show enabled sites and workbooks
6370
if args.status:
6471
show_materialized_views_status(args, password, site_content_url)
6572

6673

6774
def find_project_path(project, all_projects, path):
75+
# project stores the id of it's parent
76+
# this method is to run recursively to find the path from root project to given project
6877
path = project.name if len(path) == 0 else project.name + '/' + path
6978

7079
if project.parent_id is None:
@@ -96,6 +105,8 @@ def show_materialized_views_status(args, password, site_content_url):
96105
# For server admin, this will prints all the materialized views enabled sites
97106
# For other users, this only prints the status of the site they belong to
98107
print("Materialized views is enabled on sites:")
108+
# only server admins can get all the sites in the server
109+
# other users can only get the site they are in
99110
for site in TSC.Pager(server.sites):
100111
if site.materialized_views_enabled:
101112
enabled_sites.add(site)
@@ -160,6 +171,7 @@ def update_project(project, server, enable_materialized_views):
160171

161172

162173
def parse_workbook_path(file_path):
174+
# parse the list of project path of workbooks
163175
workbook_paths = open(file_path, 'r')
164176
workbook_path_mapping = defaultdict(list)
165177
for workbook_path in workbook_paths:

0 commit comments

Comments
 (0)
0