Commit Graph

107 Commits

Author SHA1 Message Date
Roardom
7733a7e654 fix: featured torrents counting traffic 2024-02-27 21:43:39 +00:00
HDVinnie
798d454baf Merge pull request #3561 from Roardom/peer-counts-eventual-consistency
(Update) Sync peer counts asynchronously
2024-02-23 20:59:41 -05:00
Roardom
18675b57f1 update: sync peer counts asynchronously
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.
2024-02-23 10:30:29 +00:00
Roardom
ea41dbedcc fix: edge case resulting in double announce traffic stats
When a user

1) completes a torrent (downloaded = x),
2) immediately stops it (downloaded = x),
3) resumes it (downloaded = 0) within the next 30 seconds,

then, during (1), the downloaded delta will be x, but (2) is considered overlapping (1), so it is delayed 30 seconds, by which time (3) will get processed first, having a delta of 0. After the 30 seconds are up, (2) will be processed, but since the previous processed announce (3) had a downloaded of 0, its delta will be x, causing the download to be doubled.

The same happens with upload.
2024-02-23 05:43:28 +00:00
Roardom
e9fe003b63 fix: select peer during the lock instead of before it
The peer must be selected while we hold the `WithoutOverlapping()` middleware lock. Previously, the peer was selected beforehand, which caused previous data (single digit seconds sooner) to be used to calculate the delta in the case where a user quickly sent a stopped event right after a completed event. Selecting the peer during the lock means that the data is selected and updated before any other job can process its own delta.
2024-02-14 01:26:37 +00:00
Roardom
51cbb9105c update: update slot-limited peers but exclude from peer lists
Sometimes, for whatever reason, a user might have more peers than their slot limit. This occurs because we don't ensure every user completes every download they start. This means a user could stop a torrent, clear the slot, and start a new one, and then resume the first one using peers cached by the client. When a user did this, the peer that was stopped would no longer be shown by the tracker and stats weren't affected. When the user completed the torrent, they got a error saying they couldn't send a completed event without first sending a started event. This could only be resolved by restarting the client or pausing/resuming the torrent which would reset the stats for that torrent session. This PR accounts for this fact and will allow peers updates to continue, but the user will no longer be able to receive peers in the peer list, and other users won't receive their peer in the list.
2024-02-08 00:59:50 +00:00
HDVinnie
e99067156f fix: connectable check
- hex2bin is already performed in the DTO
2024-02-04 22:43:47 -05:00
HDVinnie
31e1fc813a fix: import 2024-02-04 20:51:57 -05:00
Roardom
9ad5bed8e2 update: use queued announce updates
There were very minor edge cases with the previous system that had issues when users paused a torrent immediately after they completed it, causing data to be duplicated. We now opt to use DTOs to transfer the data into the job queue instead of models to prevent the extra database queries caused by passing models into a job queue.
2024-02-04 20:45:09 -05:00
HDVinnie
338c0d88d4 update: ProcessAnnounce.php
- this condition is already in AnnounceController
2024-01-29 19:01:30 -05:00
Roardom
66660b9c5e fix: phpstan level 7 errors in Jobs 2024-01-07 17:21:12 +00:00
Roardom
04f6e5c517 fix: peer connectivity cache key 2023-12-05 04:19:56 +00:00
Roardom
2c10ccb2bd fix: peer connectability check
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.
2023-11-27 23:48:16 +00:00
Roardom
cfa417de3b update: inline announce processing job into announce 2023-09-04 10:02:44 +00:00
Roardom
3763cce7f1 update: inline some announce job variables 2023-09-04 09:49:03 +00:00
Roardom
b287d1e431 update: announce partial freeleech logic and documentation 2023-09-04 09:44:42 +00:00
Roardom
7d90019e44 refactor: add more comments to announce 2023-09-04 09:43:29 +00:00
Roardom
6ff630139c update: torrent seeder/leecher/times_completed relatively 2023-09-04 09:40:54 +00:00
Roardom
26bdeca374 refactor: inline peer upsert array creation
Remove some code duplication.
2023-09-04 09:37:53 +00:00
Roardom
be0936af27 update: remove redundant peer update
The peer is already updated automatically through Laravel's upsert.
2023-09-04 09:36:48 +00:00
Roardom
dce02a6a7a refactor: clarify that announce uploaded/downloaded are deltas 2023-09-04 09:36:15 +00:00
Roardom
7161b85a23 refactor: organize announce job if statement conditions 2023-09-04 09:35:01 +00:00
Roardom
13d3973220 update: change torrent seeder/leecher counts relatively 2023-09-04 09:34:41 +00:00
Roardom
31e7b73549 update: deconstruct announce job switch statement 2023-09-04 09:34:01 +00:00
HDVinnie
88d114c526 PHP Style Change (Laravel Pint CI) 2023-08-30 09:39:04 +00:00
Roardom
dd7c80012b fix: upsert ordering
We want a queue and not a stack. I.e. first in first out, not first in last out.
2023-08-07 07:52:35 +00:00
HDVinnie
e89b90cec8 Merge pull request #3027 from Roardom/history-upsert-take-3
(Update) Upsert history records take 3
2023-08-06 21:35:28 -04:00
Roardom
d8dc3fd766 fix: downloaded announce logic 2023-08-05 05:52:19 +00:00
Roardom
5538be360e Revert "Revert "update: don't fetch history record before updating it""
This reverts commit 0aed738cb7.
2023-08-05 04:52:02 +00:00
Roardom
62f7bad6dc fix: torrent seeder/leecher count 2023-08-04 18:46:47 +00:00
Roardom
0aed738cb7 Revert "update: don't fetch history record before updating it"
This reverts commit 6f795b07ea.
2023-08-02 01:54:15 +00:00
HDVinnie
9d2613e7b0 Merge pull request #2988 from Roardom/lowercase-event
(Update) Lowercase the announce event at beginning
2023-07-31 21:49:23 -04:00
HDVinnie
f776991059 Merge pull request #2975 from Roardom/update-history-upserts
(Update) Don't fetch history record before updating it
2023-07-31 21:48:43 -04:00
Roardom
9ed19c1593 update: lowercase the announce event at beginning
No need to keep converting it.
2023-07-30 01:20:11 +00:00
Roardom
6f795b07ea update: don't fetch history record before updating it 2023-07-28 20:08:20 +00:00
HDVinnie
dc4b12963b Merge branch '7.x.x' into fix-personal-fl-caching 2023-07-28 02:35:16 -04:00
Roardom
2f10728ec0 fix: personal freeleech caching
We're constantly querying for personal freeleech existence if we only store it when it's true.
2023-07-28 06:13:50 +00:00
Roardom
bb5255d968 Revert "update: cache personal freeleech existence instead of its value"
This reverts commit b48a9222d1.
2023-07-28 06:08:55 +00:00
Roardom
4825ac53a2 fix: freeleech token caching
We're constantly querying for freeleech token existence if we only store it when it's true.
2023-07-28 06:05:39 +00:00
Roardom
b5246a0e80 Revert "fix: redundant fetching of records from the database"
This reverts commit 7d3a9e244e.
2023-07-28 05:21:31 +00:00
Roardom
2392da1310 Revert "fix: laravel default job model serialization"
This reverts commit 55d03d3819.
2023-07-28 05:20:33 +00:00
Roardom
fa6ef2a65c Revert "update: announce job"
This reverts commit 2524a978ab.
2023-07-28 05:20:31 +00:00
Roardom
624abb8644 Revert "fix: announce user update"
This reverts commit ef29310cd3.
2023-07-28 05:20:28 +00:00
Roardom
ef29310cd3 fix: announce user update 2023-07-28 03:27:37 +00:00
HDVinnie
2524a978ab update: announce job 2023-07-27 23:24:55 -04:00
Roardom
55d03d3819 fix: laravel default job model serialization
laravel by default automatically serializes models in a custom way when inserted into a job queue and fetches the model from the database again when the job is ran. We would rather not have these extra queries, so we can't pass in models, or data that is already serialized (as laravel will try to deserailize our serialization too and fail), so we opted for arrays, and filling in the properties into a new model again once the job is handled.
2023-07-27 03:11:04 +00:00
HDVinnie
3a26e4ae1c PHP Style Change (Laravel Pint CI) 2023-07-26 04:23:48 +00:00
HDVinnie
0d31d20d8a Merge branch '7.x.x' into fix-process-announce-selects 2023-07-26 00:22:46 -04:00
HDVinnie
b2a6bf1ac3 Merge pull request #2959 from Roardom/personal-freeleech-ttl
(Update) Cache personal freeleech existence instead of its value
2023-07-25 23:19:48 -04:00
HDVinnie
282dfb272d fix: ProcessAnnounce.php
- was accidentally removed by me in https://github.com/HDInnovations/UNIT3D-Community-Edition/pull/2565
2023-07-25 23:19:22 -04:00