|
36 | 36 |
|
37 | 37 | # Constants |
38 | 38 | BASE_URL = "https://www.googleapis.com/customsearch/v1" |
39 | | -FILE1_COUNT = os.path.join(PATHS["data_phase"], "gcs_1_count.csv") |
40 | | -FILE2_LANGUAGE = os.path.join( |
| 39 | +FILE1_COUNT = shared.path_join(PATHS["data_phase"], "gcs_1_count.csv") |
| 40 | +FILE2_LANGUAGE = shared.path_join( |
41 | 41 | PATHS["data_phase"], "gcs_2_count_by_language.csv" |
42 | 42 | ) |
43 | | -FILE3_COUNTRY = os.path.join(PATHS["data_phase"], "gcs_3_count_by_country.csv") |
| 43 | +FILE3_COUNTRY = shared.path_join( |
| 44 | + PATHS["data_phase"], "gcs_3_count_by_country.csv" |
| 45 | +) |
44 | 46 | GCS_CX = os.getenv("GCS_CX") |
45 | 47 | GCS_DEVELOPER_KEY = os.getenv("GCS_DEVELOPER_KEY") |
46 | 48 | HEADER1_COUNT = ["PLAN_INDEX", "TOOL_IDENTIFIER", "COUNT"] |
47 | 49 | HEADER2_LANGUAGE = ["PLAN_INDEX", "TOOL_IDENTIFIER", "LANGUAGE", "COUNT"] |
48 | 50 | HEADER3_COUNTRY = ["PLAN_INDEX", "TOOL_IDENTIFIER", "COUNTRY", "COUNT"] |
| 51 | +PLAN_COMPLETED_INDEX = 2868 |
49 | 52 | QUARTER = os.path.basename(PATHS["data_quarter"]) |
50 | 53 |
|
51 | 54 | # Log the start of the script execution |
@@ -139,11 +142,11 @@ def get_last_completed_plan_index(): |
139 | 142 |
|
140 | 143 |
|
141 | 144 | def load_plan(): |
142 | | - path = [] |
| 145 | + plan = [] |
143 | 146 | file_path = os.path.join(PATHS["data"], "gcs_query_plan.csv") |
144 | 147 | with open(file_path, "r", newline="") as file_obj: |
145 | | - path = list(csv.DictReader(file_obj, dialect="unix")) |
146 | | - return path |
| 148 | + plan = list(csv.DictReader(file_obj, dialect="unix")) |
| 149 | + return plan |
147 | 150 |
|
148 | 151 |
|
149 | 152 | def append_data(args, plan_row, index, count): |
@@ -259,9 +262,10 @@ def main(): |
259 | 262 | args = parse_arguments() |
260 | 263 | shared.log_paths(LOGGER, PATHS) |
261 | 264 | service = get_search_service() |
| 265 | + shared.git_fetch_and_merge(args, PATHS["repo"]) |
262 | 266 | initialize_all_data_files(args) |
263 | 267 | last_completed_plan_index = get_last_completed_plan_index() |
264 | | - if last_completed_plan_index == 2868: |
| 268 | + if last_completed_plan_index == PLAN_COMPLETED_INDEX: |
265 | 269 | LOGGER.info(f"Data fetch completed for {QUARTER}") |
266 | 270 | return |
267 | 271 | plan = load_plan() |
@@ -299,5 +303,5 @@ def main(): |
299 | 303 | ), |
300 | 304 | " ", |
301 | 305 | ) |
302 | | - LOGGER.exception(f"(1) Unhandled exception:\n{traceback_formatted}") |
| 306 | + LOGGER.critical(f"(1) Unhandled exception:\n{traceback_formatted}") |
303 | 307 | sys.exit(1) |
0 commit comments