From 09f2c137d1013f47b801956e1df4d62f358e1fc1 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Tue, 24 Sep 2024 10:15:53 +0200 Subject: [PATCH] ui fix --- src/lib/components/CommunitySentiment.svelte | 2 +- src/routes/stocks/[tickerID]/+layout.server.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/components/CommunitySentiment.svelte b/src/lib/components/CommunitySentiment.svelte index 56aa0a89..7902a187 100644 --- a/src/lib/components/CommunitySentiment.svelte +++ b/src/lib/components/CommunitySentiment.svelte @@ -90,7 +90,7 @@ $: { What do you think of {$stockTicker} today? - The community is {upvote > downvote ? 'bullish' : upvote < downvote ? 'bearish' : 'neutral'} about {$displayCompanyName} this week, , with {totalVote} total votes. + The community is {upvote > downvote ? 'bullish' : upvote < downvote ? 'bearish' : 'neutral'} about {$displayCompanyName} this week, with {totalVote} total votes. diff --git a/src/routes/stocks/[tickerID]/+layout.server.ts b/src/routes/stocks/[tickerID]/+layout.server.ts index 89f80e71..b384db63 100644 --- a/src/routes/stocks/[tickerID]/+layout.server.ts +++ b/src/routes/stocks/[tickerID]/+layout.server.ts @@ -46,13 +46,14 @@ const fetchWatchlist = async (pb, userId) => { const fetchCommunitySentiment = async (pb, ticker, cookies) => { const cookieVote = cookies.get(`community-sentiment-${ticker}`); const today = new Date().toISOString().split("T")[0]; - const tomorrow = new Date(new Date().setDate(new Date().getDate() + 7)) + const pastNDays = new Date(new Date().setDate(new Date().getDate() - 7)) .toISOString() .split("T")[0]; const output = await pb.collection("sentiment").getFullList({ - filter: `ticker="${ticker}" && created >= "${today}" && created < "${tomorrow}"`, + filter: `ticker="${ticker}" && created < "${today}" && created >= "${pastNDays}"`, }); + return { alreadyVoted: cookieVote || null, sentimentData: output?.at(0) || {},