Image board engine, Danbooru-style.
Find a file
rr- 06ab98fa70 server/search: fix sort:random breaking tags
Using sqlalchemy's subqueryload to fetch tags works like this:

1. Get basic info about posts with query X
2. Copy query X
3. SELECT all tags WHERE post_id IN (SELECT post_ids FROM query X)
4. Associate the resulting tags with the posts

When original query contains .order_by(func.random()), it looks like
this:

1. SELECT post.* FROM post ORDER BY random() LIMIT 10
2. Copy "ORDER BY random() LIMIT 10"
3. SELECT tag.* FROM tag WHERE tag.post_id IN (
       SELECT id FROM post ORDER BY random() LIMIT 10)
4. Disaster! Each post now has completely arbitrary tags!

To circumvent this, we replace eager loading with lazy loading. This
generates one extra query for each result row, but it has no chance of
producing such anomalies. This behavior is activated only for
queries containing "sort:random" and derivatives so it shouldn't hit
performance too much.
2016-08-27 01:21:59 +02:00
client client/css: fix wrapping tags in read-only sidebar 2016-08-26 23:52:03 +02:00
server server/search: fix sort:random breaking tags 2016-08-27 01:21:59 +02:00
.gitignore server/tests: switch to pytest 2016-04-15 18:00:06 +02:00
API.md server/search: add content-checksum 2016-08-26 16:26:06 +02:00
config.yaml.dist server/db: allow full DSN; use memdb in tests 2016-08-16 21:42:09 +02:00
INSTALL.md server/db: allow full DSN; use memdb in tests 2016-08-16 21:42:09 +02:00
README.md docs/readme: update links to roadmap 2016-04-17 17:24:19 +02:00

This repository is under the process of being rewritten. Stay tuned! You can check the current progress on client here and server here.

The reasons behind this rewrite include:

  • Improving user experience: better upload form, larger thumbnails, making top navigation stay out of user way. Maybe other goodies!
  • Finally having good, well-documented REST API.
  • Simplifying user registration.
  • Replacing PHP with Python 3.5.
  • Replacing prior JS mess with proper MVC.
  • Replacing MySQL (MariaDB) with Postgres.
  • Replacing composer, npm, mod_rewrite (=Apache), imagick, ffmpeg or gnash and pdo_mysql with just pip, npm and ffmpeg.
  • Replacing grunt with npm scripts.
  • Making hosting more flexible: offer simple self hosted application that can be combined with any reverse proxy.