Commit graph

15878 commits

Author SHA1 Message Date
justcool393
31e14d896f Errors: fix missing error handler for 409 2023-02-16 19:55:23 -06:00
justcool393
9453a5d074 Fix search page 2023-02-16 18:54:34 -06:00
justcool393
31f273ca32 Pins: fix infinite recursion 2023-02-16 18:46:43 -06:00
justcool393
d728a16a19 Fix :pepodroll: 2023-02-16 18:30:03 -06:00
justcool393
ba96decb9b Jinja2: add SORTS_COMMON and SORTS_ALL 2023-02-16 18:27:16 -06:00
justcool393
384b4fbd22 . -> ~ 2023-02-16 18:25:18 -06:00
justcool393
09308f17d1 Add keyword argument pins to sort_comment_results 2023-02-16 18:17:21 -06:00
justcool393
9ba4f1a8af Remove unnecessary DESC constant 2023-02-16 18:02:26 -06:00
justcool393
5f73302b28 Sorting: add comments sort for comments and constantify sorts 2023-02-16 17:52:43 -06:00
Ben Rog-Wilhelm
0af172d173
Shift a bunch of root-directory files into a new less-cluttered bootstrap directory. 2023-02-15 14:54:09 -06:00
Ben Rog-Wilhelm
9da3451ed9
Remove explicit Docker container names to allow storing multiple in parallel. 2023-02-15 14:05:08 -06:00
Ben Rog-Wilhelm
0f1bd0ff1a Minor README tweaks. 2023-02-12 20:22:16 -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
Ben Rog-Wilhelm
358674d39f Tweaks to seed_db to allow an sqlalchemy update, plus a test. 2023-02-12 13:41:55 -06:00
Ben Rog-Wilhelm
27f7207f38 Add an override value for the number of active cores to use. 2023-02-12 11:15:04 -06:00
Snakes
84e5c7c651
Merge branch 'frost' into feature-award-feature-flag 2023-02-11 23:41:41 -05:00
justcool393
1e9ca62892 sanitize: prevent worker crash during timeouts
because themotte is ~~webscale~~ async, there is some window of time
where code in the sanitize fn will cause the entire worker to crash and
not in a fun way. anyway this uses gevent to handle timeouts instead of
a signal based system which is non-portable and is very fragile,
especially if themotte adds more async functionality in (something that
would probably further improve the performance of the site)

essentially... we don't want the failure of one request taking down the
entire worker!
2023-02-10 14:09:25 -06: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
5d6641c890 remove Comment.print() and Submission.print() functions
these functions i don't believe exist upstream and i guess were to
diagnose an issue with author_ids not being saved properly. anyway not
really useful now as if an author_id doesn't exist, some major db
corruption has prolly already happened.
2023-02-10 14:01:28 -06:00
TLSM
7139e510be Future-proof flask_limiter.Limiter.__init__
We currently use Flask-Limiter 2.7.0. Upgrading to 3.1.0 breaks
because of a breaking change to keyword order. Yes, seriously:

https://flask-limiter.readthedocs.io/en/stable/changelog.html#v3-0-0

Not updating the lockfile here, pending @ZorbaTHut testing some infra
updates; however, this is necessary to be able to do so, and it still
works in 2.7.0.
2023-02-10 13:56: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
379c7d5144 add features to templates 🤤 2023-02-09 10:37:57 -06:00
justcool393
fc81ed11bf awards: don't load JS if disabled 2023-02-09 10:16:15 -06:00
justcool393
f4445fd58e award feature: use feature flag in more places 2023-02-09 10:12:49 -06:00
justcool393
a863b9c957 awards: remove vestiges of awards that don't exist anymore 2023-02-08 18:22:32 -06:00
justcool393
026a9efe2b user/submission/comment: avoid queries if awards are disabled 2023-02-08 17:54:12 -06:00
justcool393
004adcd5fe add SQLALCHEMY_WARN_20 env var to env 2023-02-08 15:50:51 -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
TLSM
946ee6291d Hide flair if should_hide_username in comments
Fixes #497.
2023-02-08 14:49:27 -06:00
justcool393
97c9300a6f
volunteer: hide usernames and scores in volunteer (ref #454) 2023-02-07 07:04: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
justcool393
4a280e345a style: remove unnecessary str call (the thing is already a str!) 2023-02-07 07:00:41 -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
Ben Rog-Wilhelm
984a613868
Merge pull request #490 from TLSM/pr-fix-comment-perf
Fix comment eager loading
2023-02-07 06:58:35 -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
9bf2f76819
deps: freeze SQLAlchemy to [1.4.43, 2.0) (SemVer), python to [3.10, 4.x) 2023-02-07 04:32:06 -06:00
TLSM
175f9c1d22 Cleanup sidebar sizing style kludges
The 15-line <pre> block at the bottom of the sidebar was a fix for
mobile hamburger menu behavior on upstream, where the long mobile
sidebar would be covered by the bottom navigation drawer.

In-place replacement would be `margin-bottom: 15em`, but it's not
actually necessary for the sidebar as used on TheMotte, and it adds
an unsightly block of whitespace to the bottom of the homepage.

Also the `style` attribute width was related to `GET /sidebar`
behavior (sidebar.html), which is unused on TheMotte, having been
replaced in the signup template with a link to `/rules`.
2023-02-04 04:13:18 -06:00
TLSM
7a9a3f7c99 Randomize sidebar recommendation order (#483)
Fixes #483. Implement a Jinja template filter to shuffle a sequence
(which surprisingly doesn't already exist) and shuffle the relevant
lists in the sidebar.
2023-02-04 04:13:18 -06:00
Ben Rog-Wilhelm
50b098f740 Add Femradebates to the link list. 2023-02-04 01:35:09 -06:00
justcool393
9ee7b73929 fix scrolling bug (#279)
ref: f7ca9aa24822d8361fd6fa939c0492711629682b on Aevann1/rDrama
2023-01-25 08:39:46 -06: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
Ben Rog-Wilhelm
fd2b2f9380
Merge pull request #459 from faul-sname/themotte-issue-451
[#451] Add count of collapsed comments in the collapsed comment thingy
2023-01-14 03:15:54 -06:00