Skip to content

Commit

Permalink
total amount of recs is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
ErnestaP committed Apr 24, 2024
1 parent 0ec8f99 commit d4ed997
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions dags/common/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ def __init__(self, input, current_year):
class DataFetchError(Exception):
def __init__(self, status_code, url):
super().__init__(f"Data fetch failure, status_code={status_code}, url={url}")


class NotFoundTotalCountOfRecords(Exception):
def __init__(
self,
):
super().__init__("Total count of records is not found!")
6 changes: 3 additions & 3 deletions dags/open_access/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import backoff
import requests
from common.exceptions import DataFetchError, WrongInput
from common.exceptions import DataFetchError, NotFoundTotalCountOfRecords, WrongInput
from open_access.parsers import get_golden_access_records_ids


Expand All @@ -29,7 +29,7 @@ def get_gold_access_count(total, url):
count = count + 1
response = get_data(full_url)
if response.status_code != 200:
raise DataFetchError(url, response.status_code)
raise DataFetchError(urls=url, status_code=response.status_code)
golden_access_records_ids_count = golden_access_records_ids_count + len(
get_golden_access_records_ids(response.text)
)
Expand All @@ -46,7 +46,7 @@ def get_total_results_count(data):
total_records_count = match.group(1)
return int(total_records_count)
except AttributeError:
return 0
raise NotFoundTotalCountOfRecords


closed_access_query = (
Expand Down

0 comments on commit d4ed997

Please sign in to comment.