summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandrewkenreich <andrew.kenreich@gmail.com>2023-03-06 11:04:20 -0500
committerandrewkenreich <andrew.kenreich@gmail.com>2023-03-06 11:04:20 -0500
commit20c6a5696b444ef8b563138f8c0048c96f75d5bb (patch)
treefc7e2e841d91c9bc435abc3214e31e9b43815cc6
parentd4521f5f4dba489ad90edeb9577482127a688c87 (diff)
fixing some date things
-rw-r--r--frontend-components/tables/src/components/Table.tsx2
-rw-r--r--openbb_terminal/core/plots/web/main_table.js2
-rw-r--r--openbb_terminal/stocks/discovery/disc_controller.py2
-rw-r--r--openbb_terminal/stocks/discovery/seeking_alpha_view.py56
4 files changed, 32 insertions, 30 deletions
diff --git a/frontend-components/tables/src/components/Table.tsx b/frontend-components/tables/src/components/Table.tsx
index d6d737d1911..9762d2c684e 100644
--- a/frontend-components/tables/src/components/Table.tsx
+++ b/frontend-components/tables/src/components/Table.tsx
@@ -226,7 +226,7 @@ export default function Table({ data, columns }: any) {
if (typeof value === "string") {
return <p>{value}</p>;
}
- return <p>{new Date(value).toISOString().split("T")[0]}</p>;
+ return <p>{new Date(value).toISOString()}</p>;
}
const valueFormatted =
valueType === "number" ? formatNumberMagnitude(value) : value;
diff --git a/openbb_terminal/core/plots/web/main_table.js b/openbb_terminal/core/plots/web/main_table.js
index 7183160522c..f4b49958bb4 100644
--- a/openbb_terminal/core/plots/web/main_table.js
+++ b/openbb_terminal/core/plots/web/main_table.js
@@ -78,7 +78,7 @@ function processData(data) {
{
title: "Age",
field: "age",
- sorter: "number",
+ sorter: "number",
}
],
data: {
diff --git a/openbb_terminal/stocks/discovery/disc_controller.py b/openbb_terminal/stocks/discovery/disc_controller.py
index 2dc04104065..52e3605022c 100644
--- a/openbb_terminal/stocks/discovery/disc_controller.py
+++ b/openbb_terminal/stocks/discovery/disc_controller.py
@@ -790,7 +790,7 @@ class DiscoveryController(BaseController):
action="store",
dest="s_type",
choices=self.cnews_type_choices,
- default="Top-News",
+ default="top-news",
help="number of news to display",
)
parser.add_argument(
diff --git a/openbb_terminal/stocks/discovery/seeking_alpha_view.py b/openbb_terminal/stocks/discovery/seeking_alpha_view.py
index 5fa11a68368..7584cd16d0d 100644
--- a/openbb_terminal/stocks/discovery/seeking_alpha_view.py
+++ b/openbb_terminal/stocks/discovery/seeking_alpha_view.py
@@ -114,22 +114,24 @@ def news(
if article_id == -1:
articles = seeking_alpha_model.get_trending_list(limit)
- if export:
- df_articles = pd.DataFrame(articles)
-
- for idx, article in enumerate(articles):
- console.print(
- article["publishedAt"].replace("T", " ").replace("Z", ""),
- "-",
- article["id"],
- "-",
- article["title"],
- )
- console.print(article["url"])
- console.print("\n")
-
- if idx >= limit - 1:
- break
+ df_articles = pd.DataFrame(articles)
+
+ print(df_articles.head(limit))
+ df_articles["publishedAt"] = pd.to_datetime(df_articles["publishedAt"])
+
+ df_news = pd.DataFrame(
+ df_articles, columns=["publishedAt", "id", "title", "url"]
+ )
+
+ # We look for a date name in the column to assume its a date on frontend side for filtering etc
+ df_news.rename(columns={"publishedAt": "publishedAtDate"}, inplace=True)
+
+ df_news = df_news.drop("id", axis=1)
+ print_rich_table(
+ df_news.head(limit),
+ show_index=False,
+ export=bool(export),
+ )
# User wants to access specific article
else:
@@ -161,7 +163,7 @@ def news(
@log_start_end(log=logger)
def display_news(
- news_type: str = "Top-News",
+ news_type: str = "top-news",
limit: int = 5,
export: str = "",
sheet_name: Optional[str] = None,
@@ -184,16 +186,16 @@ def display_news(
console.print("No news found.", "\n")
else:
- for news_element in news_to_display:
- console.print(
- news_element["publishOn"]
- + " - "
- + news_element["id"]
- + " - "
- + news_element["title"]
- )
- console.print(news_element["url"])
- console.print("\n")
+ df_news = pd.DataFrame(
+ news_to_display, columns=["publishOn", "id", "title", "url"]
+ )
+ df_news = df_news.drop("id", axis=1)
+ print_rich_table(
+ df_news.head(limit),
+ show_index=False,
+ title=f"{news_type}",
+ export=bool(export),
+ )
export_data(
export,