Does anybody have a package or pattern for good, scalable “Likes” or “Stars” counting (like on GitHub)? It’s not an entirely trivial problem, so I don’t want to reinvent the while if somebody has already written a solid, pure Elixir package for this. I did some searching but couldn’t find anything on Google or GitHub.
If you’re looking for techniques/utilities to crawl the pages of GitHub, or the like, I don’t have any immediate recommendations. Googling for “GitHub crawler” or looking for List API endpoints, e.g. Users - GitHub Docs (e.g. getting all users, then fanning out to their repos), may be entrypoints.
No no no, sorry, I mean to implement a system similar to github stars. As in, you’ve got your Things table, you’ve got your User table, you’ve got your UserLikesThing table. The naive implementation is pretty simple, but can get ugly when counting really really popular things, getting summary statistics, etc. I was wondering if there was a “Likes” package which solved the common hiccups, maybe with a GenServer/cache already.
I don’t have an answer, but I have questions for the OP.
Do you have any reference materials (technical blog posts, papers, etc.) that can help us understand the implementation pitfalls you’re referring to for the naive implementation & how they can be addressed? It’d be nice for anyone who comes across this and doesn’t have familiarity with the problem space to be able to contextualize the issue.
Are there any reference implementations in other languages that you could point to that address this? Being able to hear a “like package X in Ruby/Python/etc.” could spark recognition if an Elixir library does exist, and if one doesn’t exist, knowing what a reference implementation does could lead to either developing an idiomatic approach as a library or presenting a pattern where Elixir/OTP magic makes the implementation trivial enough to not need a library.
Looking forward to having some resources I could use to expand my own understanding if you’re able to provide them, so thanks in advance for indulging my request.
Their solution is simple though, pretty much what I described above, and to be honest I think I’m overthinking this problem - I’m not at the scale where it matters. I’ll just do it with a simple little table. Thanks for your time!
Sorry, my mistake!
Along with the Django example, this ER diagram looks like it may be useful for the schema impl: mysql - Implementing Comments and Likes in database - Stack Overflow.
Kind of what I’d expect for something like that. Having user+likes as one N:N table referencing users and the entity. That way you can track what a user has like as well as sum up the total likes for an entity. Don’t even need all the inheritance stuff if you’re just liking one thing.
Something like this would probable “scale” well enough in a RDBMS like postgres for some time.