maxim
I wrote a library for building leaderboards. Would love any feedback. This is the list of features from the readme:
- Ranks, percentiles, any custom stats of your choice
- Concurrent reads, sequential writes
- Stream API access to records from the top and the bottom
- O(1) querying of any record by id
- Auto-populating data on leaderboard startup
- Adding, updating, removing, upserting of individual entries in live leaderboard
- Fetching a range of records around a given id (contextual leaderboard)
- Pluggable data stores:
EtsStorefor big boards,TermStorefor dynamic mini boards - Atomic full repopulation in ~O(2n log n) time
- Multi-node support
- Extensibility for storage engines (
CxLeaderboard.Storagebehaviour)
Trending in Announcing
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
I released Doggo, a collection of unstyled Phoenix components.
https://github.com/woylie/doggo
Features
Unstyled Phoenix components....
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hello
Published a new library - ProcessHub!
ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
I’ve started working on a new library to run SQL queries and do basic business intelligence.
Think “Blazer for Elixir.”
Currently it fe...
New
Other Trending Topics
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
This showed up on my feed.. anyone heard of it? Just hype?
Ox Alpha is a reasoning model designed for coding, sustained ag...
New
Hey folks,
I just published a post about Hologram’s funding and where the project goes next - the short version:
Curiosum as Main Spons...
New
:microphone: ElixirConf 2026 - Call for Talks is open!
We’re heading to Chicago :united_states:
:round_pushpin: In person + virtual
:d...
New
What IDE or editor are you using for Elixir development?
Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
idi527
For the term storage,
:gb_treesmight be a better fit than lists in maps.I think DemonWare used them together with ets to keep rankings in call of duty. But that was before maps were introduced.
maxim
Wow that presentation is full of interesting insights, thank you! And gb_trees looks like a useful structure, will read more about it (esp. once erlang documentation site starts loading for me).
idi527
I wanted to link it but the website was down for me as well … You can do
erl -man gb_treesin your shell.amnu3387
I’ll probably give it a try soon
maxim
Let me know how it goes or if you need any help/have questions. Happy to help.
jonathanleang
Can I get a example for Postgres auto-populate on startup.
I got the following but can’t get it to work. I think my issue is the connection is closed when the transaction ended.
related issue. Using Postgrex.stream with transactions · Issue #373 · elixir-ecto/postgrex · GitHub
worker(CxLeaderboard.Leaderboard, [:global, [data: loadDataToLeaderboard(pid)]])
def loadDataToLeaderboard(pid) do
{:ok, stream} = Postgrex.transaction(pid, fn(conn) →
Postgrex.stream(conn, “SELECT id, elo FROM users”, , max_rows: :infinity, timeout: :infinity)
end)
stream
end
maxim
@jonathanleang Interesting. I’ve never tried using these Ecto streams, I don’t think they play too well with a case where the stream should live for a long time. In our case I wrote my own module called
StreamExtand implemented a couple of streaming functions in it. One based on offset/limit, and another (more efficient one) based on id comparisons.maxim
Hey, just following up, did you manage to make it work?
jonathanleang
@maxim
Thanks for following up, I have been trying for some time now, but kind of stuck.
here is what I got now.
maxim
Ah I see, let me give you a specific solution here. I kind of forgot that my batch function wasn’t for direct usage. Try the following:
Add this file to your elixir project: stream_ext.ex · GitHub
Use this function:
And finally declare your worker like this:
Let me know if this works.