maz

maz

Paginator Cursor Missing Items

I have a query containing a relatively complicated join and there are 85 items total.

Strangely, after sending the second after cursor no more items return(Paginator never returns more than 60 items).

This is the query:

  defp list_media_items_by_channel_slug_query(channel_slug, :feed) do
    from(m in MediaItem,
      join: con in ContentMediaItems,
      on: m.id == con.media_item_id,
      join: chan in assoc(con, :channel),
      where: chan.slug == ^channel_slug,
      preload: [:mediaitemartifacts],
      order_by: [{:desc, :inserted_at}]
    )
  end

Called like:

        %{entries: entries, metadata: metadata} =
          Repo.paginate(
            query,
            include_total_count: true,
            after: after_cursor,
            sort_direction: sort_direction,
            cursor_fields: cursor_fields,
            limit: 30
          )

The first cursor returns another 30, but the second cursor returns nothing, but when I get the full list there are 85 items(so the cursor should return 25, but actually returns 0).

Repo.all(query) # returns 85

I’m baffled. The 25 items are there but I don’t get them returned?

Elixir 1.16.1 (compiled with Erlang/OTP 26)
ecto 3.11.2
paginator, 1.1.0

Marked As Solved

maz

maz

I found a fix, and you led me down the trail, thanks.

cursor_fields: [:inserted_at, :title],

If I use these two columns, it gives the paginator enough to work with and I receive the correct result sets. I think a lot of the inserted_at dates are too similar.

Where Next?

Popular in Questions Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New

We're in Beta

About us Mission Statement