Last active
December 19, 2024 23:03
-
-
Save Ghost-chu/10f01aab255bce407327e8e2e21cc8cf to your computer and use it in GitHub Desktop.
Revisions
-
Ghost-chu revised this gist
Dec 19, 2024 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ SELECT DISTINCT ban.peerIp FROM BanHistory ban WHERE ban.insertTime >= ?1 AND ban.insertTime <= ?2 AND ban.module LIKE '%ProgressCheatBlocker%' GROUP BY ban.peerIp, time_bucket(?4, ban.insertTime) HAVING COUNT(DISTINCT ban.userApplication.appId) >= ?3 -
Ghost-chu created this gist
Dec 19, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ WITH LatestSnapshots AS ( SELECT DISTINCT ON (s.torrent, s.peer_ip, s.user_application) s.id, s.torrent, s.peer_ip, s.user_application, s.to_peer_traffic, s.last_time_seen FROM public.peer_history s WHERE s.last_time_seen >= ? AND s.to_peer_traffic > 0 ORDER BY s.torrent, s.peer_ip, s.user_application, s.last_time_seen DESC ), AggregatedUploads AS ( SELECT ls.torrent, ls.peer_ip, SUM(ls.to_peer_traffic) AS total_uploaded FROM LatestSnapshots ls GROUP BY ls.torrent, ls.peer_ip HAVING SUM(ls.to_peer_traffic) > 0 ) SELECT au.torrent, au.peer_ip, au.total_uploaded, t.size, (au.total_uploaded / t.size::float) * 100 AS upload_percentage FROM AggregatedUploads au JOIN public.torrent t ON au.torrent = t.id WHERE t.size::float > 0 AND au.total_uploaded > t.size::float * ? ORDER BY upload_percentage DESC;