Skip to content

Commit c9bb230

Browse files
SNOW-2853362 Added summary_json file (#31)
1 parent 4c91f39 commit c9bb230

File tree

1 file changed

+26
-0
lines changed
  • DBX/workspace_extractor_package/src/workspace_extractor

1 file changed

+26
-0
lines changed

DBX/workspace_extractor_package/src/workspace_extractor/manager.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,32 @@ def show_results(self, days: int | str) -> None:
7676
print(f"The following information was collected by the Workspace Estimator for the last {days} days")
7777
for key, value in self.results_count.items():
7878
print(f"{key.upper().ljust(10)}:\t{value}")
79+
self.results_count["date_range"] = days
80+
self.write_results_count_json()
81+
82+
def write_results_count_json(self, filename: str = "summary") -> None:
83+
"""Write the results_count dictionary to a JSON file using the Util class.
84+
85+
Saves the current results_count dictionary containing the counts of different
86+
data types collected to a JSON file in the configured output directory.
87+
88+
Args:
89+
filename (str): Name of the output file (without extension).
90+
Defaults to "summary".
91+
92+
Returns:
93+
None
94+
95+
Side Effects:
96+
- Creates a JSON file in the output directory
97+
- File will be named "{filename}.json"
98+
99+
Example:
100+
manager.write_results_count_json("summary_counts")
101+
# Creates: ./output/summary_counts.json
102+
103+
"""
104+
Util.write_file_request_(self.output, filename, self.results_count)
79105

80106
def generator(self) -> Generator[None, None, None]:
81107
"""Create an infinite generator for pagination loops.

0 commit comments

Comments
 (0)