Skip to content

Commit

Permalink
fix: migrate to new SGID Index spreadsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
stdavis committed Apr 2, 2024
1 parent 0b73038 commit 9221507
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"python.linting.enabled": true,
"python.linting.pycodestyleEnabled": false,
"python.formatting.provider": "none",
"cSpell.words": [
"accesstoken",
"agol",
Expand Down
44 changes: 30 additions & 14 deletions src/conductor/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"""
Expand All @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/conductor/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 9221507

Please sign in to comment.