@@ -71,7 +71,25 @@ final public function bonEarnings(): \Illuminate\Support\Collection
71
71
{
72
72
$ outerQuery = DB ::query ();
73
73
$ innerQuery = Peer::query ()
74
- ->join ('history ' , fn ($ join ) => $ join ->on ('history.torrent_id ' , '= ' , 'peers.torrent_id ' )->on ('history.user_id ' , '= ' , 'peers.user_id ' ))
74
+ ->select ([
75
+ 'peers.torrent_id ' ,
76
+ 'peers.user_id ' ,
77
+ 'torrents.name ' ,
78
+ 'torrents.created_at as torrent_created_at ' ,
79
+ 'torrents.size ' ,
80
+ 'torrents.seeders ' ,
81
+ 'torrents.leechers ' ,
82
+ 'torrents.times_completed ' ,
83
+ 'torrents.internal ' ,
84
+ 'torrents.personal_release ' ,
85
+ 'torrents.type_id ' ,
86
+ 'history.seedtime ' ,
87
+ 'peers.connectable '
88
+ ])
89
+ ->join ('history ' , function ($ join ): void {
90
+ $ join ->on ('history.torrent_id ' , '= ' , 'peers.torrent_id ' )
91
+ ->on ('history.user_id ' , '= ' , 'peers.user_id ' );
92
+ })
75
93
->join ('torrents ' , 'peers.torrent_id ' , '= ' , 'torrents.id ' )
76
94
->where ('peers.seeder ' , '= ' , true )
77
95
->where ('peers.active ' , '= ' , true )
@@ -87,16 +105,16 @@ final public function bonEarnings(): \Illuminate\Support\Collection
87
105
foreach ($ bonEarning ->conditions as $ condition ) {
88
106
$ conditionQuery .= ' AND ' .match ($ condition ->operand1 ) {
89
107
'1 ' => '1 ' ,
90
- 'age ' => 'TIMESTAMPDIFF(SECOND, torrents.created_at , NOW()) ' ,
91
- 'size ' => 'torrents. size ' ,
92
- 'seeders ' => 'torrents. seeders ' ,
93
- 'leechers ' => 'torrents. leechers ' ,
94
- 'times_completed ' => 'torrents. times_completed ' ,
95
- 'internal ' => 'torrents. internal ' ,
96
- 'personal_release ' => 'torrents. personal_release ' ,
97
- 'type_id ' => 'torrents. type_id ' ,
98
- 'seedtime ' => 'history. seedtime ' ,
99
- 'connectable ' => 'peers. connectable ' ,
108
+ 'age ' => 'TIMESTAMPDIFF(SECOND, torrent_created_at , NOW()) ' ,
109
+ 'size ' => 'size ' ,
110
+ 'seeders ' => 'seeders ' ,
111
+ 'leechers ' => 'leechers ' ,
112
+ 'times_completed ' => 'times_completed ' ,
113
+ 'internal ' => 'internal ' ,
114
+ 'personal_release ' => 'personal_release ' ,
115
+ 'type_id ' => 'type_id ' ,
116
+ 'seedtime ' => 'seedtime ' ,
117
+ 'connectable ' => 'connectable ' ,
100
118
}.' ' .$ condition ->operator .' ' .$ condition ->operand2 ;
101
119
}
102
120
0 commit comments