99from ted_sws .event_manager .services .log import log_warning
1010from ted_sws .notice_fetcher .adapters .ted_api_abc import TedAPIAdapterABC , RequestAPI
1111
12- DEFAULT_TED_API_QUERY_RESULT_SIZE = {"limit" : 100 ,
12+
13+ DOCUMENTS_PER_PAGE = 100
14+
15+ DEFAULT_TED_API_QUERY_RESULT_SIZE = {"limit" : DOCUMENTS_PER_PAGE ,
1316 "page" : 1 ,
1417 "scope" : "ALL" ,
1518 }
@@ -43,7 +46,7 @@ def __call__(self, api_url: str, api_query: dict) -> dict:
4346 response_content = json .loads (response .text )
4447 return response_content
4548 else :
46- raise Exception (f"The TED-API call failed with: { response } , { response . content } , { api_url } " )
49+ raise Exception (f"The TED-API call failed with: { response } " )
4750
4851
4952class TedAPIAdapter (TedAPIAdapterABC ):
@@ -123,7 +126,7 @@ def get_generator_by_query(self, query: dict, result_fields: dict = None) -> Gen
123126 query .update (result_fields or DEFAULT_TED_API_QUERY_RESULT_FIELDS )
124127 response_body = self .request_api (api_url = self .ted_api_url , api_query = query )
125128 documents_number = response_body [TOTAL_DOCUMENTS_NUMBER ]
126- result_pages = 1 + int (documents_number ) // 100
129+ result_pages = 1 + int (documents_number ) // DOCUMENTS_PER_PAGE
127130 documents_content = response_body [RESPONSE_RESULTS ]
128131 if result_pages > 1 :
129132 for page_number in range (2 , result_pages + 1 ):
@@ -136,7 +139,6 @@ def get_generator_by_query(self, query: dict, result_fields: dict = None) -> Gen
136139 # document_id = "0" * (11 - len(document_id)) + document_id
137140 # document_content[DOCUMENT_NOTICE_ID_KEY] = document_id
138141 del document_content [LINKS_TO_CONTENT_KEY ]
139- print ("content exist" )
140142 yield document_content
141143 else :
142144 for document_content in documents_content :
0 commit comments