@@ -44,27 +44,36 @@ def main():
44
44
print ("Use '--type <content type> --mode <enable/disable>' to update materialized views settings." )
45
45
return
46
46
47
+ # enable/disable materialized views for site
47
48
if args .type == 'site' :
48
49
if not update_site (args , enable_materialized_views , password , site_content_url ):
49
50
return
50
51
52
+ # enable/disable materialized views for workbook
53
+ # works only when the site the workbooks belong to are enabled too
51
54
elif args .type == 'workbook' :
52
55
if not update_workbook (args , enable_materialized_views , password , site_content_url ):
53
56
return
54
57
58
+ # enable/disable materialized views for project by project name
59
+ # will show possible projects when project name is not unique
55
60
elif args .type == 'project_name' :
56
61
if not update_project_by_name (args , enable_materialized_views , password , site_content_url ):
57
62
return
58
63
64
+ # enable/disable materialized views for proejct by project path, for example: project1/project2
59
65
elif args .type == 'project_path' :
60
66
if not update_project_by_path (args , enable_materialized_views , password , site_content_url ):
61
67
return
62
68
69
+ # show enabled sites and workbooks
63
70
if args .status :
64
71
show_materialized_views_status (args , password , site_content_url )
65
72
66
73
67
74
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
68
77
path = project .name if len (path ) == 0 else project .name + '/' + path
69
78
70
79
if project .parent_id is None :
@@ -96,6 +105,8 @@ def show_materialized_views_status(args, password, site_content_url):
96
105
# For server admin, this will prints all the materialized views enabled sites
97
106
# For other users, this only prints the status of the site they belong to
98
107
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
99
110
for site in TSC .Pager (server .sites ):
100
111
if site .materialized_views_enabled :
101
112
enabled_sites .add (site )
@@ -160,6 +171,7 @@ def update_project(project, server, enable_materialized_views):
160
171
161
172
162
173
def parse_workbook_path (file_path ):
174
+ # parse the list of project path of workbooks
163
175
workbook_paths = open (file_path , 'r' )
164
176
workbook_path_mapping = defaultdict (list )
165
177
for workbook_path in workbook_paths :
0 commit comments