Skip to content

Commit

Permalink
Update notice_fetcher.py
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainOfHacks committed Feb 26, 2024
1 parent af42992 commit f35b1ca
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions ted_sws/notice_fetcher/services/notice_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,21 @@ def fetch_notices_by_query(self, query: dict) -> List[str]:
#documents = self.ted_api_adapter.get_by_query(query=query)
documents = self.ted_api_adapter.get_generator_by_query(query=query)
notice_ids = set()
for document in documents:
notice_ids.add(document["ND"])
print(f"downloaded Notice: ", document["ND"])
self.notice_repository.add(notice=self._create_notice(notice_data=document))
while True:
try:
document = next(documents, None)

if document is None:
break
notice_ids.add(document["ND"])
print(f"downloaded Notice: ", document["ND"])
self.notice_repository.add(notice=self._create_notice(notice_data=document))
except Exception as e:
print(e)
# for document in documents:
# notice_ids.add(document["ND"])
# print(f"downloaded Notice: ", document["ND"])
# self.notice_repository.add(notice=self._create_notice(notice_data=document))
#return self._store_to_notice_repository(documents=documents)
return list(notice_ids)

Expand Down

0 comments on commit f35b1ca

Please sign in to comment.