Skip to content

Needs to be changed to account for less than 100 posts/users #4

@marcelluseasley

Description

@marcelluseasley

if len(allPosts) >= 100 {

if len(sortedUsers) >= 100 {

What if the subreddit is small and contains less than 100 posts or 100 users? Then the relative cache key won't be set...neither will the relative channel. The logic may need to be changed to the following....

if len(allPosts) >= 100 {
	allPosts = allPosts[:100]
}
s.resultsCache.Set(s.redditClient.Config.SubReddit+ "#posts", allPosts, cache.NoExpiration)
s.postDataChannel <- allPosts

if len(sortedUsers) >= 100 {
	sortedUsers = sortedUsers[:100]
}	
s.resultsCache.Set(s.redditClient.Config.SubReddit+ "#users", sortedUsers, cache.NoExpiration)
s.userCountChannel <- sortedUsers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions