From 922150753397e67a40762fff25e440a6edfc42b9 Mon Sep 17 00:00:00 2001 From: stdavis Date: Tue, 2 Apr 2024 12:08:09 -0600 Subject: [PATCH] fix: migrate to new SGID Index spreadsheet --- .vscode/settings.json | 3 --- src/conductor/checks.py | 44 ++++++++++++++++++++++++++------------ src/conductor/conductor.py | 2 +- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 5356e80..c885f3a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,4 @@ { - "python.linting.enabled": true, - "python.linting.pycodestyleEnabled": false, - "python.formatting.provider": "none", "cSpell.words": [ "accesstoken", "agol", diff --git a/src/conductor/checks.py b/src/conductor/checks.py index 7d9aeb7..46998ca 100644 --- a/src/conductor/checks.py +++ b/src/conductor/checks.py @@ -309,12 +309,17 @@ class GSheetChecker: """look for a record and attributes in the stewardship worksheet""" required_fields = [ - "Description", - "Data Source", - "Website URL", - "Data Type", - "Endpoint", - "Deprecated", + "displayName", + "description", + "justification", + "category", + "productType", + "ugrcSteward", + "dataContactEmail", + "dataContactName", + "porterUrl", + "productPage", + "itemId", ] client = None worksheet = None @@ -339,7 +344,7 @@ def _get_data(self): header_row = self.worksheet.get_row(1) self.build_header_row_index(header_row) - return self.worksheet.find(self.table, matchEntireCell=True) + return self.worksheet.find(self.table.split(".")[1], matchEntireCell=True, cols=(1, 12)) def exists(self): """tests for if the row exists in the sheet""" @@ -364,15 +369,26 @@ def exists(self): fields = self.field_index starting_position = cell.col + product_page = None + item_id = None for key, position in fields.items(): - status[key] = False - delta = (0, (position + 1) - starting_position) value = cell.neighbour(delta).value.strip() + if key == "productPage": + product_page = value + elif key == "itemId": + item_id = value + continue + + status[key] = False if value: status[key] = True + if not item_id and not product_page: + status["productPage"] = False + status["itemId"] = False + return SheetResponse(True, status) @staticmethod @@ -388,26 +404,26 @@ def grade(add, report_value): [ f"\n| - {key} | :no_entry: |" for key in report_value.messages - if not report_value.messages[key] and key != "Deprecated" + if not report_value.messages[key] and key != "porterUrl" ] ) success = "".join( [ f"\n| - {key} | :+1: |" for key in report_value.messages - if report_value.messages[key] and key != "Deprecated" + if report_value.messages[key] and key != "porterUrl" ] ) return f" |{failures}{success}".rstrip(" |").strip("\n\n") #: removal - has_linked_deprecation_issue = report_value.messages["Deprecated"] + has_linked_deprecation_issue = report_value.messages["porterUrl"] if not has_linked_deprecation_issue: - return " |\n| - deprecation issue link | :no_entry:" + return " |\n| - porter issue link | :no_entry:" - return " |\n| - deprecation issue link | :+1:" + return " |\n| - porter issue link | :+1:" @staticmethod def create_client_with_service_account(file_path): diff --git a/src/conductor/conductor.py b/src/conductor/conductor.py index 92ec68c..322980e 100644 --- a/src/conductor/conductor.py +++ b/src/conductor/conductor.py @@ -203,7 +203,7 @@ def exception_catcher(report_name): check = GSheetChecker( table, "11ASS7LnxgpnD0jN4utzklREgMf1pcvYjcXcIcESHweQ", - "SGID Stewardship Info", + "SGID Index", secrets["sheets-sa"], ) reports[table].append(Report("stewardship", issue, check.exists(), GSheetChecker.grade))