diamondburned
01/05/24 06:45AM
Hypnohub Popular Query Generator
Hi everyone!

Ever since Hypnohub migrated to the newer booru software, one feature that I've missed a lot is the Popular feature, which displays daily, weekly, and monthly popular posts. I've come across some workarounds, but they require a significant amount of effort.

Because of that, I've created a website that automatically generates popular queries, so you don't have to! It is located at:

>>> popularhypnohub.diamondx.pet <<<

To use it, simply choose one of the three buttons: "Daily Popular," "Weekly Popular," or "Monthly Popular," and a query will be generated. Clicking the spiral button will take you directly to Hypnohub.

--- Nerdy details below! ---

The service internally uses the Hypnohub API. It is also heavily cached: a daily query is generated only once a day at most, and each cache miss should perform only a handful (around 20 max) of requests, so it really should not introduce a lot more traffic.

The service works by utilizing binary searching. It starts off at an arbitrarily high page number, then divides the posts in half repeatedly until it finds a post that roughly matches the "daily," "weekly," or "monthly" mark. The time complexity for this is O(log_2 n) with some optimizations, so for 5000 posts, only a maximum of 12 requests are needed.

The project is completely open source and available on GitHub at github.com/diamondburned/hypnoview. If you like the project and are on GitHub, feel free to give it a star!
Detour
01/05/24 03:46PM
Oh that's really interesting, and seems to work well.

Using it for a bit does seem to expose one error though, the time periods are consistently doubled from what I can see.

E.g. daily popular uses ID's going back to 2 days ago, 18 days for weekly and for monthly the first available ID is from November 1st.
diamondburned
01/06/24 10:55AM
Detour said:

E.g. daily popular uses ID's going back to 2 days ago, 18 days for weekly and for monthly the first available ID is from November 1st.


Some of this is actually intentional! Specifically, the code defines that:

- Day: posts that were created yesterday are also included.
- Week: posts made from last week are included, unless the current day is Sunday, then posts from this week (Last Monday to Sunday) are included.
- Month: posts made from last month are included as well, unless we're over two weeks into the current month.

So the "yesterday" behavior for daily is correct, but the weekly and monthly are wrong! I've pushed a commit to fix this, so it should actually work normally now.

Admittedly, the rules for this are rather arbitrary, so I would be happy to adopt something better and more intuitive!
1


Reply | Forum Index