The query only takes 6 seconds on my local untuned machine. Caching it for an hour is probably fine, we have worse queries out there, and indexing isn't an option since this table is write-heavy. Reduces overall complexity and prevents blank page after cache is reset.
The external tracker handles the upserts (`auto:upsert_peers`,
`auto:upsert_histories`, and `auto:upsert_announces`), handles
incrementing/decrementing the seeders/leeches/times_completed
(`auto:sync_peers`), and handles incrementing/decrementing the
balance (`auto:torrent_balance`).
The external tracker keeps track of leech slots internally, so
the leech slot caching isn't needed and as a result, shouldn't
be touched inside the `auto:flush_peers` command either.
There's no inaccurate stats issues that could happen if these
commands are run, but a normal 200 ms 3000-record upsert from
the external tracker takes 2-3 seconds if they happen at the
same time as the `auto:sync_peers` or `auto:torrent_balance`
commands are being run.
Makes announce processing job code easier to deal with. There is negligible performance loss (<5%) by querying the peer count realtime on the torrents and torrent pages.
Updating all of a user's peers to either be connectable or unconnectable causes deadlocks when updated at the same time as a bulk peer upsert. We need to combine the peer connectability updates with the regular bulk peer upserts.
Mark peers for deletion via this column so that they can be mass deleted later. This allows for combining peer inserts, updates and deletions into a single bulk peer upsert queue. Otherwise, when a user stops and starts a torrent before the bulk peer updates are collected in the queue, the peer may be deleted immediately after it gets inserted.
- history still needs too be made to upsert
- connectable logic needs updating
- $peer->delete() in job needs to be reworked
The only solution would be to instead of deleting it on stopped event, make another column on the peers table for is_active and update is_active to 1 in every case except for stopped, in which case update it to 0 instead of deleting and then a cron job can delete it later.
Co-Authored-By: Roardom <78790963+Roardom@users.noreply.github.com>
- github action updated with new ruleset in pint.json
- codebase linted with new ruleset
- contributors can now run `./vendor/bin/pint`
- action workflow will auto correct any lint issues upon commit/opened pull request