diff --git a/relay/trending/basic.go b/relay/trending/basic.go index 4ad7785..6db2554 100644 --- a/relay/trending/basic.go +++ b/relay/trending/basic.go @@ -8,22 +8,12 @@ import ( "git.highperfocused.tech/highperfocused/lumina-relay/relay/cache" ) -type Post struct { - ID string `json:"id"` - PubKey string `json:"pubkey"` - CreatedAt time.Time `json:"created_at"` - Kind string `json:"kind"` - Content string `json:"content"` - Tags [][]string `json:"tags"` - ReactionCount int `json:"reaction_count"` -} - var ( trendingCache = cache.New() cacheDuration = 5 * time.Minute ) -// GetTrendingKind20 returns the top 20 trending posts of kind 20 from the last 24 hours +// GetTrendingBasicKind20 returns the top 20 trending posts of kind 20 from the last 24 hours func GetTrendingBasicKind20(db *sql.DB) ([]Post, error) { if cached, ok := trendingCache.Get("trending_kind_20"); ok { return cached.([]Post), nil diff --git a/relay/trending/score.go b/relay/trending/score.go index 7bdbc87..5a23fda 100644 --- a/relay/trending/score.go +++ b/relay/trending/score.go @@ -5,7 +5,7 @@ import ( "encoding/json" ) -// GetTrendingKind20 returns the top 20 trending posts of kind 20 from the last 24 hours +// GetTrendingScoreKind20 returns the top 20 trending posts of kind 20 from the last 24 hours func GetTrendingScoreKind20(db *sql.DB) ([]Post, error) { if cached, ok := trendingCache.Get("trending_kind_20"); ok { return cached.([]Post), nil @@ -45,7 +45,7 @@ func GetTrendingScoreKind20(db *sql.DB) ([]Post, error) { e.kind, e.content, e.tags, - COALESCE(s.trending_score, 0) as reaction_count + COALESCE(s.trending_score, 0.0) as reaction_count -- Cast to float FROM event e LEFT JOIN scores s ON e.id = s.original_event_id WHERE e.kind::text = '20' diff --git a/relay/trending/types.go b/relay/trending/types.go new file mode 100644 index 0000000..3b3b5a7 --- /dev/null +++ b/relay/trending/types.go @@ -0,0 +1,13 @@ +package trending + +import "time" + +type Post struct { + ID string `json:"id"` + PubKey string `json:"pubkey"` + CreatedAt time.Time `json:"created_at"` + Kind int `json:"kind"` + Content string `json:"content"` + Tags [][]string `json:"tags"` + ReactionCount float64 `json:"reaction_count"` +}