Skip to content

Commit

Permalink
fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
hanniabu committed May 24, 2024
1 parent 3b7a157 commit 9938c14
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion _data/smoothing-pools-processed.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"smooth":{"validators_active":1914,"validators_pending":13,"validators_total":1927},"smoothly":{"validators_active":55,"validators_pending":66,"validators_total":121}}
{"smooth":{"validators_active":1934,"validators_pending":12,"validators_total":1946},"smoothly":{"validators_active":56,"validators_pending":65,"validators_total":121}}
Binary file not shown.
Binary file modified _scripts/__pycache__/hardware.cpython-312.pyc
Binary file not shown.
Binary file added _scripts/__pycache__/job_listings.cpython-312.pyc
Binary file not shown.
Binary file modified _scripts/__pycache__/smoothing_pools.cpython-312.pyc
Binary file not shown.
Binary file modified _scripts/__pycache__/utilities.cpython-312.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions _scripts/collect_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@


def run_app():
update_smoothing_pool_data()
check_hardware_availability()
# update_smoothing_pool_data()
# check_hardware_availability()
update_job_listings()
update_for_hire_listings()
# update_for_hire_listings()



Expand Down
2 changes: 1 addition & 1 deletion _scripts/for_hire_listings.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def update_for_hire_listings():
save_listing_data(processed_data)
except:
error = f"Bad response"
utilities.log(f"{error}: {metric_id}_{data_source}")
utilities.log(f"{error}: {script_id}")
utilities.report_error(error, context=f"{script_id}__update_for_hire_listings")


2 changes: 1 addition & 1 deletion _scripts/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def check_hardware_availability():
save_unavailable_products_data(updated_unavailable_products)
else:
error = f"Bad response"
utilities.log(f"{error}: {metric_id}_{data_source}")
utilities.log(f"{error}: {script_id}")
utilities.report_error(error, context=f"{script_id}__check_hardware_availability")
return

Expand Down
24 changes: 17 additions & 7 deletions _scripts/job_listings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ def get_listing_data():
}
# get the sheet data
# reference: https://docs.gspread.org/en/v5.7.0/user-guide.html
print("gc...")
gc = gspread.service_account_from_dict(credentials)
sheet = gc.open_by_key("1FN73olU-8djRhfGqEc7-2LsjfwR6Qqj0T3Y5-bfxHqs").worksheet("Job Listings")
print("sheet...")
sheet = gc.open_by_key(utilities.SHEETS_URL).worksheet("Job Listings")
print("sheet_data...")
sheet_data = sheet.get_all_records()
# utilities.log(sheet_data, context=f"{script_id}__get_listing_data")
utilities.log(sheet_data, context=f"{script_id}__get_listing_data")
return sheet_data

def process_listing_data(raw_data):
Expand Down Expand Up @@ -69,11 +72,18 @@ def save_listing_data(processed_data):
def update_job_listings():
try:
raw_data = get_listing_data()
except Exception as e:
print(e)
try:
processed_data = process_listing_data(raw_data)
except Exception as e:
print(e)
try:
save_listing_data(processed_data)
except:
error = f"Bad response"
utilities.log(f"{error}: {metric_id}_{data_source}")
utilities.report_error(error, context=f"{script_id}__update_job_listings")

except Exception as e:
print(e)
# except:
# error = f"Bad response"
# utilities.log(f"{error}: {script_id}")
# utilities.report_error(error, context=f"{script_id}__update_job_listings")

3 changes: 1 addition & 2 deletions _scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# gspread==6.1.2
gspread==5.7.0
gspread==5.12.4
python-dotenv==1.0.1
PyYAML==6.0.1
PyYAML==6.0.1
Expand Down
2 changes: 1 addition & 1 deletion _scripts/smoothing_pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def update_smoothing_pool_data():
save_smoothing_pool_data(smooth_subs, smoothly_subs)
else:
error = f"Bad response"
utilities.log(f"{error}: {metric_id}_{data_source}")
utilities.log(f"{error}: {script_id}")
utilities.report_error(error, context=f"{script_id}__update_smoothing_pool_data")
return

2 changes: 1 addition & 1 deletion _scripts/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

load_dotenv()
GOOGLE_TOKEN = os.environ.get("GOOGLE_TOKEN")

SHEETS_URL = os.environ.get("SHEETS_URL")


def fetch(url, method="GET", payload={}, headers={}, retries=2, delay=0, retry_delay=0, context="", data_type="json"):
Expand Down

0 comments on commit 9938c14

Please sign in to comment.