GemCopeland / personal-website

A website of my very own
GNU General Public License v3.0
44 stars 8 forks source link

Clarify system for displaying Arena blocks #45

Closed GemCopeland closed 4 years ago

GemCopeland commented 4 years ago

@piperhaywood You have probably explained it to me already, but what's the system behind which blocks display on the Thinking panel?

I'm confused because the ones in the Spinners channel are the newest blocks, but in My Work they're the oldest ones.

piperhaywood commented 4 years ago

Currently we’re getting the contents of the channel and then just grabbing the first 10 blocks that have images. I would have expected the order to match the order within the channel, but that’s not what’s happening.

It seems like it may be in the order of the date/time that each block was first added to that particular channel, but that’s not a metric that we have access to in the block object. The only things we have access to that could feasibly be used for ordering are title, id, updated_at, and created_at, and none of these seem to be what is creating the order.

Let’s talk more about this... We may have to consider just randomising the blocks or something like that.

piperhaywood commented 4 years ago

When I inspect the channel object though (for example, the channel “Commoning”), there is an added_to_at property. That looks promising, but I don’t understand why that doesn’t exist for the blocks. Making a note here to look in to it.

GemCopeland commented 4 years ago

Ok cool. I'd be happy with just randomising the blocks btw, especially for this launch version.

piperhaywood commented 4 years ago

@GemCopeland Ok so I think I figured this out...

It has to do with the pagination. The API returns 25 blocks at a time by default. You can raise this limit with the per parameter, but it seems like there’s a hard upper-limit of 100. Within each page, the blocks are in their order of position.

The problem is that the pages themselves are returned in reverse order of what I would expect. I had a look at the docs and couldn’t find much about this. I then inspected the queries using the Apollo inspector and found that sort_by and direction parameters do exist, but these don’t seem to be exposed in the public API.

This means that our random idea would never work since we’re not able to get all of the blocks at once (understandable, Arena has to put limitations on things!).

Instead, I’m going to calculate the total pages and then use that in a for loop to go through the pages in reverse order and gather the images. We’ll break the for loop when there are enough images present.

piperhaywood commented 4 years ago

Fixed in v0.3