Commit Graph

20 Commits

Author SHA1 Message Date
Eva
7823682b39 server/search: allow negating sort:pool 2025-04-01 08:22:41 +02:00
2ff79a6aa2 server/search: support sorting post search results by pool post order 2025-04-01 08:22:16 +02:00
57193b5715 client+server: implement code autoformatting using prettier and black 2020-06-06 08:58:23 -04:00
rr-
1c4c5c5f91 remove tags.json 2017-10-01 21:48:00 +02:00
rr-
4bc58a3c95 server: lint 2017-04-24 23:30:53 +02:00
rr-
e4aa38f159 server/search: fix errors on negative page offsets 2017-04-24 22:12:12 +02:00
rr-
fdad08e176 server: use index-based paging (#123) 2017-02-09 22:40:00 +01:00
rr-
ad842ee8a5 server: refactor + add type hinting
- Added type hinting (for now, 3.5-compatible)
- Split `db` namespace into `db` module and `model` namespace
- Changed elastic search to be created lazily for each operation
- Changed to class based approach in entity serialization to allow
  stronger typing
- Removed `required` argument from `context.get_*` family of functions;
  now it's implied if `default` argument is omitted
- Changed `unalias_dict` implementation to use less magic inputs
2017-02-05 16:34:45 +01:00
rr-
abf1fc2b2d server: make linters happier 2017-02-03 22:42:14 +01:00
rr-
995cd4610d server: drop old style class declarations 2016-10-22 14:43:52 +02:00
rr-
b0c5031001 client+server/posts: reverse next/prev post role
In the post list, when we navigate to the page with ">" button, we
navigate to older posts.
In the post view, when we navigate to the page with ">" button, we
navigate to older posts as well.

However, in the post list, the ">" button is called "next page".
At the same time, in the post view, the ">" button was called "previous
post". Now it's called "next post".

The difference isn't visible to normal users nor even API consumers as
the "get posts around post X" request isn't documented.

The change is motivated not only by consistency, but to also improve
compatibility with Vimperator's `[[` and `]]`. Vimperator assumes the
word "next" refers to ">" and the word "previous" refers to "<".
2016-10-02 17:07:08 +02:00
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
rr-
6d26b5c37a server/search: fix sort:random 2016-08-26 23:27:33 +02:00
rr-
48af5160df server/search: fix negative offsets causing ISE 2016-08-16 17:22:33 +02:00
rr-
9aea55e3d1 server/general: embrace most of PEP8
Ignored only the rules about continuing / hanging indentation.

Also, added __init__.py to tests so that pylint discovers them. (I don't
buy pytest's BS about installing your package.)
2016-08-14 16:44:03 +02:00
rr-
36eddad424 server/posts: optimize 'posts around' query 2016-06-14 07:50:22 +02:00
rr-
dfb2e3d027 server/posts: add getting posts around id
Leave undocumented since it add almost no value for the client
applications.
2016-06-08 22:38:35 +02:00
rr-
8a5c6f0b31 server/search: fix caching special tokens
special:liked was being reused between users. Now the cache internally
caches object similar to liked:USER.
2016-06-03 19:47:09 +02:00
rr-
f0d3589344 server/search: cache by query rather than its text 2016-06-03 19:47:09 +02:00
rr-
59ad5fe402 server/search: refactor, extract parsing 2016-06-03 19:47:09 +02:00