File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,8 @@ poetry run python main.py --company google --timeframe 3m
113
113
114
114
This will fetch the most asked questions at Google in the last 3 months.
115
115
116
+ The options for ` --timeframe ` are: ` 30d ` , 3m` , or ` 6m`.
117
+
116
118
## Running Tests
117
119
118
120
Run the tests with the following command:
Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ def get_recent_questions_for_company(
179
179
:param difficulties: The list of difficulties to filter the questions (default is ['EASY', 'MEDIUM']).
180
180
:param top_n: The number of top questions to retrieve (default is 50).
181
181
:return: A dictionary containing the list of questions.
182
- :raises Exception: If the API request fails or the response does not contain expected data.
182
+ :raises Exception: If the company does not exist, or the API request fails or the response does not contain expected data.
183
183
184
184
"""
185
185
if difficulties is None :
@@ -222,11 +222,16 @@ def get_recent_questions_for_company(
222
222
response .raise_for_status () # Raise an exception for HTTP errors
223
223
224
224
response_data = response .json ()
225
+
225
226
if (
226
227
"data" not in response_data
227
- or "favoriteQuestionList" not in response_data ["data" ]
228
- or "questions" not in response_data ["data" ]["favoriteQuestionList" ]
228
+ or response_data ["data" ].get ("favoriteQuestionList" ) is None
229
229
):
230
+ raise Exception (
231
+ f"No data found for company '{ company_slug } ' within the timeframe '{ timeframe } '. The company might not exist or no questions are available."
232
+ )
233
+
234
+ if "questions" not in response_data ["data" ]["favoriteQuestionList" ]:
230
235
raise Exception ("Questions not found or invalid response format" )
231
236
232
237
# Limit to top N questions
You can’t perform that action at this time.
0 commit comments