Commit Graph

87 Commits

Author SHA1 Message Date
Shyam Sunder 2dfd1c2192 server/search: add MD5-based search 2021-01-05 13:51:39 -05:00
Shyam Sunder 57193b5715 client+server: implement code autoformatting using prettier and black 2020-06-06 08:58:23 -04:00
Shyam Sunder ea623449e7 server: format code to flake8 2020-06-05 10:02:18 -04:00
Ruin0x11 e6bf102bc0 Add list of posts to pools 2020-05-04 00:09:33 -07:00
Ruin0x11 d59ecb8e23 Add pool CRUD operations/pages 2020-05-03 19:53:28 -07:00
Shyam Sunder 4117f63375 server/model/posts: Make post flags a hybrid attribute in model
This should (hopefully) fix #250 and #252
2019-04-22 20:20:19 -04:00
Shyam Sunder d69ef710b3 server/search: automatically add wildcards for source URL searching 2019-04-07 19:30:35 +02:00
Shyam Sunder 1d8cfd5a89 server/search: allow searching by source URL content 2019-04-07 19:30:35 +02:00
Shyam Sunder 3879c2ec20 server/search: allow searching by post flags 2018-09-24 11:36:13 +02: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- ba4df16499 server/search: add search term escaping 2017-04-24 21:59:38 +02:00
rr- 9814b132c3 server/search: fix searching for ---
Allow only one negation sign.
Also throw an error if user searches only for "-".
2017-04-24 19:55:02 +02:00
rr- fdad08e176 server: use index-based paging (#123) 2017-02-09 22:40:00 +01:00
rr- 00c3a4320b server/posts: support aspect-ratio search query 2017-02-05 22:09:33 +01:00
rr- 0b21d98c9b server/posts: support note-text search query 2017-02-05 21:51:53 +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- 9b27e113b3 server/search: escape backslashes in search 2017-01-21 00:22:53 +01:00
rr- 7414d1f7a6 server/posts: fix getting posts around
Querying this undocumented API resulted in 500 ISE unless the client
asked only for the "id" field.
2017-01-20 22:17:26 +01:00
rr- 627574a9c2 server: make pylint happier 2017-01-03 21:35:08 +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- 560a7d6839 server/search: prefer arrays over ranges
(No, it doesn't work recursively.)
Also fix tests.
2016-09-26 22:48:09 +02:00
rr- 1e65622daf server/search: don't be a hardass about strings
Let range criteria (values that contain ..) that end up being used as
strings, to be used as if they were simple criteria. So let the user
search for "when_you_see_it..." and don't throw a warning.
2016-09-26 22:48:09 +02:00
rr- 1bd8af47b0 server/search: match only [a-z-]* for named tokens
Adds ability to search for *:* for example. Still not perfect, but it's
a start.
2016-09-26 22:06:18 +02:00
rr- 0e31e1fd14 server/search: fix underscores and percentages
Escape them for LIKE statements.
2016-09-26 21:58:27 +02:00
rr- c366b608da server/search: fix negating complex searches
Entering:

    miko -miko

is a contradiction that shouldn't have been returning any matches, but
it has nonetheless. This change fixes the construction of negated
expressions that use subqueries.
2016-08-28 18:43:05 +02:00
rr- 3c5878cb16 server/tags: improve tag list performance 2016-08-27 22:19:01 +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- f8e91a10e8 server/search: refactor query factories 2016-08-27 01:19:29 +02:00
rr- 6d26b5c37a server/search: fix sort:random 2016-08-26 23:27:33 +02:00
rr- fa60b42f65 server/search: improve post list performance 2016-08-26 17:57:20 +02:00
rr- 422b99ac8d server/search: add content-checksum 2016-08-26 16:26:06 +02:00
rr- 61d084cc66 server/search: support 'submit:' for anon uploads 2016-08-22 19:45:25 +02:00
rr- 80af79779d server/snapshots: rewrite 2016-08-16 21:51:25 +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- b7f2982c9e server/posts: fix relations bidirectionality 2016-07-17 21:14:03 +02:00
rr- c21494be25 server/posts: make relations bidirectional 2016-07-03 18:30:32 +02:00
rr- d0aaf8fa8f server/posts: optimize default sort order 2016-06-14 07:50:22 +02:00
rr- 36eddad424 server/posts: optimize 'posts around' query 2016-06-14 07:50:22 +02:00
rr- 6b68c77e17 server/posts: add relation-count token 2016-06-13 20:09:15 +02:00
rr- 40565e82ae server/posts: change comment-time behavior
Rather than looking at the edit time, now it looks at the creation time.
2016-06-12 14:24:14 +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- f3bb6c28a1 server/general: cosmetic fixes 2016-06-05 10:39:56 +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