Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolves mrusme/neonmodem#32 Filter for lemmy communities #36

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

BreadMakesYouFat
Copy link
Contributor

A possible fix for Lemmy community filtering. Tested with make + go1.19.0.

A limitation is that we currently only request 50 posts at a time, and so some communities will be empty. I tried naively upping the limit value but this seems to result in no results, so probably need to send multiple requests and I'm not very experienced with requests in go:

system/lemmy/lemmy.go
184:		Limit: types.NewOptional(int64(100)),  // This fails to retrieve any results.

@BreadMakesYouFat
Copy link
Contributor Author

Created a new issue for the limited results number here:
#37

@BreadMakesYouFat
Copy link
Contributor Author

Oh think that gets it working :)

Copy link
Owner

@mrusme mrusme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey hey, thanks for the PR! I left a couple of comments.

system/lemmy/lemmy.go Outdated Show resolved Hide resolved
system/lemmy/lemmy.go Outdated Show resolved Hide resolved
system/lemmy/lemmy.go Outdated Show resolved Hide resolved
@mrusme mrusme added the enhancement New feature or request label Jun 25, 2023
resolves mrusme#32 Filter for lemmy communities
resolves mrusme#37 Keep lemmy results 50 but query specific community
Show all subscribed lemmy communities + re-query for results from that specific community when selected
Copy link
Owner

@mrusme mrusme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Just two more questions that came to my mind, other than that good to go!

ID: strconv.Itoa(i.Community.ID),
Name: i.Community.Name,
var maxSubscriptions int
if sys.config["MaxSubscriptions"] != nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding another check that makes sure MaxSubscriptions wasn't set to 0? I fear that if someone might mistakenly change that in their config, debugging the issue might be really tricky. And from what I understand, 0 wouldn't make any sense.

} else {
maxSubscriptions = MaxSubscriptions
}
page := 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for the previous comment, I was assuming paging would start at 0. It seems like we would either want to page from 0 to < maxSubscriptions or from 1 to <= maxSubscriptions. Otherwise the configured value would not factually represent the actual amount of pages, no?

SysIDX: sys.ID,
})
}
page += 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless there was an error or the len of resp.Communities is 0, it seems like the page would always increment. Do you think it might be better to make the for loop an actual for page := 0; page <= maxSubscriptions; page++, to make this more visible? Or is there another reason you decided to go for the page += 1 at the end that I might be overseeing here? The explicit for loop would save two dedicated lines, ehehehe. :-)


var getPosts types.GetPosts
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@mrusme
Copy link
Owner

mrusme commented Nov 23, 2023

@BreadMakesYouFat any updates? :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants