Skip to content

Commit

Permalink
Sort the recommendation by date and sort the chart in sidebar by date
Browse files Browse the repository at this point in the history
  • Loading branch information
timho102003 committed Sep 13, 2023
1 parent 642b410 commit ff719d8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
st.divider()
st.area_chart(
gb_time_df,
x="yyyy-mm-dd",
x="timestamp",
y="read cnt",
)
st.divider()
Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"Entertainment",
"Business",
]
FEED_ARTICLE_NUMS = 20
FEED_ARTICLE_NUMS = 30
3 changes: 3 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def load_activities(activities):
+ "-"
+ group_by_time["d"].astype(str)
)
group_by_time['timestamp'] = pd.to_datetime(group_by_time['yyyy-mm-dd'])
group_by_time = group_by_time.sort_values(by='timestamp')
group_by_cat = df[["category", "read cnt"]].groupby(["category"]).sum()
group_by_cat = group_by_cat.reset_index()
return group_by_time, group_by_cat
Expand Down Expand Up @@ -261,6 +263,7 @@ def fetch_feeds(total_articles=12, data_range=14, thresh=0.1, mode="feed", searc
if cur_id not in unique_id:
unique_id.add(cur_id)
final_articles.append(art)
final_articles = sorted(final_articles, key=lambda x: x["payload"]['date'], reverse=True)
return final_articles

def generate_feed_layout():
Expand Down

0 comments on commit ff719d8

Please sign in to comment.