Skip to content

Commit

Permalink
Fix issue where incorrect key for biztoc prints exception (#5257)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaslek authored Jul 27, 2023
1 parent 41d1359 commit 73348c0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions openbb_terminal/common/biztoc_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def get_sources() -> pd.DataFrame:
# If data request failed
console.print("[red]Status code not 200. Unable to retrieve data\n[/red]")
df = pd.DataFrame()
return df

df = df.sort_values(by=["title"], ascending=True)
df = df[["id", "title", "web"]]
Expand Down Expand Up @@ -125,7 +126,7 @@ def get_news(
"X-RapidAPI-Key": get_current_user().credentials.API_BIZTOC_TOKEN,
"X-RapidAPI-Host": "biztoc.p.rapidapi.com",
}

df = pd.DataFrame()
while not have_data:
if term:
req = request(
Expand Down Expand Up @@ -158,7 +159,8 @@ def get_news(
break

df = pd.DataFrame(req.json(), columns=["title", "body", "url", "created"])

if df.empty:
return df
df["created"] = pd.to_datetime(df["created"])

df = df.sort_values(by=[sort], ascending=False)
Expand Down

0 comments on commit 73348c0

Please sign in to comment.