Commit graph

3777 commits

Author SHA1 Message Date
Ben Rog-Wilhelm
860eea7ba8
Merge pull request #517 from justcool393/comment-reply-sort
Sorting: add comments sort for comments and constantify sorts
2023-02-17 14:39:34 -06:00
justcool393
c5cea4f8fa add SORTS_COMMENTS 2023-02-16 23:43:08 -06:00
justcool393
31e14d896f Errors: fix missing error handler for 409 2023-02-16 19:55:23 -06:00
justcool393
ba96decb9b Jinja2: add SORTS_COMMON and SORTS_ALL 2023-02-16 18:27:16 -06:00
justcool393
09308f17d1 Add keyword argument pins to sort_comment_results 2023-02-16 18:17:21 -06:00
justcool393
5f73302b28 Sorting: add comments sort for comments and constantify sorts 2023-02-16 17:52:43 -06:00
Ben Rog-Wilhelm
efa722b676
Merge pull request #502 from justcool393/feature-award-feature-flag
user/submission/comment: avoid queries if awards are disabled
2023-02-12 20:21:54 -06:00
justcool393
873bc6d258 drop auth_desired from pp routes
fewer queries yay
2023-02-12 19:50:21 -06:00
Snakes
84e5c7c651
Merge branch 'frost' into feature-award-feature-flag 2023-02-11 23:41:41 -05:00
TLSM
9ade35d22f Eager load GET /comments ("All Comments")
Before vs after:

GET /comments
|----------|--------|--------|--------|--------|--------|------------|
| Database | SELECT | INSERT | UPDATE | DELETE | Totals | Duplicates |
|----------|--------|--------|--------|--------|--------|------------|
| default  |  167   |   0    |   0    |   0    |  167   |    154     |
|----------|--------|--------|--------|--------|--------|------------|

GET /comments
|----------|--------|--------|--------|--------|--------|------------|
| Database | SELECT | INSERT | UPDATE | DELETE | Totals | Duplicates |
|----------|--------|--------|--------|--------|--------|------------|
| default  |   13   |   0    |   0    |   0    |   13   |     0      |
|----------|--------|--------|--------|--------|--------|------------|
2023-02-10 14:07:37 -06:00
justcool393
4f8cce1093 remove externeous print statement 2023-02-10 14:01:28 -06:00
justcool393
1817008a91
remove profile songs (ref #470) (#499)
* removes profile songs (ref #470)

* Remove ffmpeg, remaining song subsystem

  - Remove references to User.song in userpage* templates
  - Generate migration to drop column
  - Remove ffmpeg dependency in Docker

* remove python 2 era __future__ import

---------

Co-authored-by: TLSM <duolsm@outlook.com>
2023-02-10 13:56:04 -06:00
justcool393
f8f55be8b0
constantify render depth limit 2023-02-10 13:54:49 -06:00
justcool393
4cecdef35a
captcha: add captcha to contact page (fixes #482) 2023-02-09 10:41:15 -06:00
justcool393
f4445fd58e award feature: use feature flag in more places 2023-02-09 10:12:49 -06:00
TLSM
007f0a3f02 Optimize comment pagination in post_id, viewmore
Against a clean seeded DB, reduces `GET /post/1/` from 63 queries to
26 by removing redundancies and slow lazy-loaded queries during
top comment pagination.

Also applies eager loading to /viewmore/ with the expected reduction
from 5*(N comments) queries to ~12/request.

For testing locally, use a newly seeded DB to ensure
Comment.descendant_count is populated.

Ref: #485
2023-02-08 15:50:24 -06:00
justcool393
86ea70dfd3 awards: remove all award definitions 2023-02-07 07:03:36 -06:00
justcool393
9211f17e25 notifs: remove notifications on block/unblock 2023-02-07 07:01:22 -06:00
TLSM
a64c0872ee Remove legacy comment pagination logic
The comments schema, prior to December 2021, used parent_comment_id
instead of also storing top_comment_id. Comment pagination is based
now on top_comment_id. However, upstream never migrated their old
comments to populate tc_id, and thus retained two copies of pagination
logic, each using different limits to try to emulate similar behavior.

TheMotte foremost has no posts created prior to December 2021 (so
these branches never activated) and also has tc_id on all comments.

The dual limit pagination approach was already removed (there is
only one limit for paginating comments). This completes the removal of
this logic, since these are purely dead codepaths which have previously
caused confusion to contributors.
2023-02-07 07:00:13 -06:00
TLSM
43f329badf
Fix Session expiry for tests
This is likely not an issue for production (since each request will
get its own SQLAlchemy session), but `scoped_session` results in the
tests reuseing the same Session across tests. The tests rely on
the default session expiry behavior.
2023-02-07 07:04:02 -05:00
TLSM
509332e9cc
Fix comment eager loading
Following #485, we began investigating post/comment rendering
bottlenecks. The most immediate issue is the eager comment loading
(merged in 23a8fb9663) did not seem fully operative: query logs
showed comments and associated FKs were being lazy loaded again
(linear query quantity in number of rendered comments). In fact,
CPU load seemed even worse than previous lazy loading.

Bisect revealed first bad commit: fb77cbcc2b
which fixed post view counters by committing the SQLAlchemy session
instead of flushing, following upstream's fix. However, committing
a session has the unfortunate side effect of dumping cached session
objects, such as the previously loaded comment objects and their
relationships, causing fallback to the old lazy behavior.

We fix this here by explicitly telling SQLAlchemy to not expire
the session on commit.

Hopefully this will simultaneously resolve the elevated DB CPU load
observed in production and speed up page rendering again.
2023-02-07 06:37:40 -05:00
justcool393
38e87e86f8 transfers: remove /transfers/ 2023-01-20 06:02:14 -06:00
justcool393
a022c09005 admin: remove merging
it was kinda borked anyway
2023-01-20 06:01:59 -06:00
justcool393
b6af1fd1f3 giphy: remove giphy 2023-01-20 06:01:34 -06:00
faul_sname
b75c93e600 Merge remote-tracking branch 'origin/frost' into themotte-issue-451 2023-01-12 22:09:07 -08:00
faul_sname
4a6ed37166 [themotte/rDrama#451] Move the pusher_thread() function from files/routes/comment.py to files/helpers/comment.py 2023-01-09 00:07:49 -08:00
justcool393
08f4cd2274 fix: volunteer duties can be None
make sure return type is correct so callees don't get an unexpected `None`
2023-01-09 00:30:20 -06:00
justcool393
712a0ad631 awards: remove tilt award 2023-01-08 19:38:20 -06:00
virtual256
da03335cb5 Replace sql_ilike_clean with func.lower for non-pattern uses; also fixes #398 2023-01-08 19:37:26 -06:00
justcool393
21676622e6 volunteer: fix missing import 2023-01-08 03:17:26 -06:00
justcool393
0ea72e3778
Debug: Add button in admin panel to login to other accounts (#437) 2023-01-08 03:16:02 -06:00
faul_sname
19e9b161d4 [themotte/rDrama#451] When a comment is removed, aggregates (post comment count, author comment count) are updated 2023-01-03 01:17:41 -08:00
faul_sname
28f4807a9b [themotte/rDrama#451] Move comment_on_publish() to files/helpers/comments.py 2023-01-03 01:11:50 -08:00
Ben Rog-Wilhelm
f4c6c7cf91 Fix: Deleted comments show up in the Janitor Volunter system. 2022-12-30 01:44:16 -06:00
Ben Rog-Wilhelm
fb77cbcc2b Fix: Post view count does not update properly. 2022-12-22 20:09:57 -06:00
Ben Rog-Wilhelm
e257db1542
Refactor test system to be more extendable, add comment test 2022-12-17 19:41:35 -06:00
Ben Rog-Wilhelm
b4efd75753 Merge branch 'frost' into pr-eager-content 2022-12-17 17:17:32 -06:00
justcool393
3f2e8629df ratelimiting: check after required request g attributes are set 2022-12-17 09:21:40 -08:00
justcool393
a213396854
Solve blocking weaponization.
* allow anyone to reply to their blockers

* revert userblocks thing

* get rid of unnecessary template

* make blocking page accurate

* comment author things

* fix prev commit

* fix block page

* comma splice

Co-authored-by: Snakes <104547575+TLSM@users.noreply.github.com>
2022-12-17 11:11:51 -06:00
justcool393
0c632d73b7
Rework error system a bit to remove a bunch of duplicated code (#434) 2022-12-01 20:58:27 -06:00
Ben Rog-Wilhelm
08602b4279 Volunteer Janitor: Minor cleanups. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
5fef5ca908 Volunteer Janitor: Add global enable/disable. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
0f91324603 Volunteer Janitor: Response recording. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
0a8bbae290 Volunteer Janitor: Record accepted tasks. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
03b323c7a1 Volunteer Janitor: Initial duty acquisition. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
e43db0535d Volunteer Janitor: Initial hooks. 2022-12-01 18:53:24 -08:00
TLSM
afe209d5d8
Eager load comments for post rendering.
GET /post/1/clever-unique-post-title-number-0
|----------|--------|--------|--------|--------|--------|------------|
| Database | SELECT | INSERT | UPDATE | DELETE | Totals | Duplicates |
|----------|--------|--------|--------|--------|--------|------------|
| default  |  942   |   0    |   1    |   0    |  943   |    921     |
|----------|--------|--------|--------|--------|--------|------------|
Total queries: 943 in 0.377s # request time in browser 17249ms

GET /post/1/clever-unique-post-title-number-0
|----------|--------|--------|--------|--------|--------|------------|
| Database | SELECT | INSERT | UPDATE | DELETE | Totals | Duplicates |
|----------|--------|--------|--------|--------|--------|------------|
| default  |   58   |   0    |   1    |   0    |   59   |     35     |
|----------|--------|--------|--------|--------|--------|------------|
Total queries: 59 in 0.0423s # request time in browser 544ms

Also, fixes seed_db not populating top_comment_id on generated
comments. If you want to test locally with seed_db test data, you need
to reseed.
2022-11-28 17:47:54 -05:00
TLSM
5aaef144cf
Deduplicate post/comment sorting & time filtering.
Ported in from upstream with adjustments for TheMotte, most notably
universal default to 'new' and fixes to 'hot'. Lumped into this PR
because eager comment loading uses it.
2022-11-28 14:33:24 -05:00
TLSM
4d22d9bce2
Eager load get_posts for submission_listings.
Ported in logic from upstream to use SQLAlchemy eager loading instead
of repeated queries when building a submission_listing. Adjusted
loaded relationships to include only those used on TheMotte.

Using test data from seed_db, before and after:

GET /
|----------|--------|--------|--------|--------|--------|------------|
| Database | SELECT | INSERT | UPDATE | DELETE | Totals | Duplicates |
|----------|--------|--------|--------|--------|--------|------------|
| default  |   83   |   0    |   0    |   0    |   83   |     72     |
|----------|--------|--------|--------|--------|--------|------------|
Total queries: 83 in 0.031s

GET /
|----------|--------|--------|--------|--------|--------|------------|
| Database | SELECT | INSERT | UPDATE | DELETE | Totals | Duplicates |
|----------|--------|--------|--------|--------|--------|------------|
| default  |   14   |   0    |   0    |   0    |   14   |     0      |
|----------|--------|--------|--------|--------|--------|------------|
Total queries: 14 in 0.00718s
2022-11-28 12:55:31 -05:00
TLSM
9953c5763c
Port get.py improvements from upstream.
Generally standardizes the get_* helpers:
 - Adds type hinting.
 - Deduplicates block property addition.
 - Respects `graceful` in more contexts.
 - More resilient to invalid user input / less boilerplate necessary
   at call-sites.
2022-11-28 12:36:04 -05:00