Browse Source

Move engagement calculation inside widget

Svilen Markov 1 year ago
parent
commit
aef0c84286
2 changed files with 1 additions and 2 deletions
  1. 0 2
      internal/feed/reddit.go
  2. 1 0
      internal/widget/reddit.go

+ 0 - 2
internal/feed/reddit.go

@@ -110,7 +110,5 @@ func FetchSubredditPosts(subreddit, sort, topPeriod, search, commentsUrlTemplate
 		posts = append(posts, forumPost)
 	}
 
-	posts.CalculateEngagement()
-
 	return posts, nil
 }

+ 1 - 0
internal/widget/reddit.go

@@ -95,6 +95,7 @@ func (widget *Reddit) Update(ctx context.Context) {
 	}
 
 	if widget.ExtraSortBy == "engagement" {
+		posts.CalculateEngagement()
 		posts.SortByEngagement()
 	}