Commit graph

35 commits

Author SHA1 Message Date
Adeodato Simó e2c9ea3cd2 Fix instances of bad-classmethod-argument in recently edited files 2024-03-17 21:28:55 -03:00
Adeodato Simó 1b9e0546e6 Bracket-wrap calls to patch() for better readability 2024-03-17 20:34:12 -03:00
Adeodato Simó 9d502f5ee2
Use setUpTestData() to speed up tests
Pylint's `bad-classmethod-argument` is disabled for each definition
to avoid rewriting the method bodies just to rename `self` → `cls`.
This can be done gradually, as the setUpTestData methods are modified
along the way.
2023-12-11 19:40:30 -03:00
Wesley Aptekar-Cassels 3e78e398c0 Switch from priority queues to function-based queues
Fixes: #2907
2023-07-20 12:25:30 -04:00
Mouse Reeve 4e3513bd41
Merge pull request #2784 from WesleyAC/add-status-cache-get-audience
Only call get_audience once in add_status
2023-04-07 06:43:04 -07:00
Wesley Aptekar-Cassels 68c6a9e748 Rename remove_object_from_related_stores
This makes the stores argument required, making it simpler to change the
code.
2023-04-05 22:06:09 -04:00
Josh Soref 9dc3cdca5d spelling: statuses
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-04 20:02:54 -04:00
Mouse Reeve c28d523e6f
Merge branch 'main' into get-audience-perf 2023-03-12 15:40:53 -07:00
Wesley Aptekar-Cassels 2a5f722f6e Optimize add/remove book statuses task queries
The queries as they previously existed required joining together 12
different tables, which is extremely expensive. Splitting it into four
queries means that the individual queries can effectively use the
indexes we have, and should be very fast no matter how many statuses are
in the database.

Removing the .distinct() call is fine, since we're adding them to a set
in Redis anyways, which will take care of the duplicates.

It's a bit ugly that we now make four separate calls to Redis (this
might result in things being slightly slower in cases where there are an
extremely small number of statuses), but doing things differently would
result in significantly more surgery to the existing code, so I've opted
to avoid that for the moment.

Fixes: #2725
2023-03-09 15:26:03 -05:00
Wesley Aptekar-Cassels 23698dafe5 Change get_audience to return list of user IDs
This will make it simpler to implement various optimizations.
2023-03-09 00:50:24 -05:00
Wesley Aptekar-Cassels 41e14bdfaf Change unread_by_status_type_id to take user ID
Same reason as in prior commit.
2023-03-09 00:50:24 -05:00
Wesley Aptekar-Cassels 653e8ee81b Change unread_id to take user ID
Same reason as described in the prior commit.
2023-03-09 00:50:24 -05:00
Wesley Aptekar-Cassels 5446869c38 Change stream_id to take user ID
Anywhere we have a user object, we can easily get the user ID in the
caller, and this will allow us more flexibility in the future to
implement optimizations that involve knowing a user ID without querying
the database for the user object.
2023-03-09 00:50:16 -05:00
Mouse Reeve 317cf5fcf5 Generate fewer add_status_tasks
Previously, every time a status was saved, a task would start to add it
to people's timelines. This meant there were a ton of duplicate tasks
that were potentially heavy to run. Now, the Status model has a "ready"
field which indicates that it's worth updating the timelines. It
defaults to True, which prevents statuses from accidentally not being
added due to ready state.

The ready state is explicitly set to false in the view, which is the
source of most of the noise for that task.
2022-11-15 14:14:32 -08:00
Mouse Reeve fdd4691e00 Adds unit test 2022-05-16 09:41:34 -07:00
Mouse Reeve a92bf785dd Updates init files for pylint 2022-04-08 14:16:05 -07:00
Mouse Reeve 85aad7c219 Another sorting order error 2022-02-03 13:25:44 -08:00
Mouse Reeve 2c7a6e8518 Correct status order 2022-02-03 13:17:16 -08:00
Mouse Reeve 224dc4100a Activitstreams tests 2022-01-28 17:32:41 -08:00
Mouse Reeve 8722778ed0 Updates tests 2022-01-06 12:13:24 -08:00
Mouse Reeve 59e6b67bc8 Activitystreams mocks 2021-12-09 20:38:44 -08:00
Mouse Reeve 0c193b6ce1 ActivityStream mocks 2021-12-09 20:33:11 -08:00
Mouse Reeve cad5a128ac Fixes call to add_status signal 2021-11-12 10:19:13 -08:00
Mouse Reeve e6a251fdad Updates mocks across tests 2021-11-12 10:07:38 -08:00
Mouse Reeve ac70a810af Boosts by remote users 2021-10-04 09:58:05 -07:00
Mouse Reeve 321949f2fa Lightly updates tests 2021-10-04 09:47:33 -07:00
Mouse Reeve 443750d6db f strings for activistreams tasks tests 2021-10-04 09:14:04 -07:00
Mouse Reeve 668f71f96c Tests block and unblock activitystream signals 2021-10-03 11:45:19 -07:00
Mouse Reeve da3bc1e591 Python formatting 2021-09-07 12:05:34 -07:00
Mouse Reeve 6bc4bf4503 Fixes mock 2021-09-07 12:02:29 -07:00
Mouse Reeve b717c2fcd8 Fixes mock arg on test 2021-09-07 11:57:18 -07:00
Mouse Reeve 82ad1abe9a more activitystreams tests 2021-09-07 11:53:41 -07:00
Mouse Reeve d147c6ac2f Separate tests into more files 2021-09-07 11:13:18 -07:00
Mouse Reeve a4041911c6 Adds tests more activitystreams tasks 2021-09-07 11:01:27 -07:00
Mouse Reeve f4b43af600 Creates test files for activitystreams 2021-09-07 10:24:09 -07:00