mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
attendance retroactive increment total_days
This commit is contained in:
@@ -326,7 +326,13 @@ class AttendanceRepository extends BaseRepository
|
|||||||
'date' => $date,
|
'date' => $date,
|
||||||
'is_retroactive' => 1,
|
'is_retroactive' => 1,
|
||||||
];
|
];
|
||||||
return AttendanceLog::query()->create($insert);
|
$attendanceLog = AttendanceLog::query()->create($insert);
|
||||||
|
//Increment total days and update days.
|
||||||
|
$attendance->update([
|
||||||
|
'total_days' => NexusDB::raw('total_days + 1'),
|
||||||
|
'days' => $this->getContinuousDays($attendance, Carbon::today()),
|
||||||
|
]);
|
||||||
|
return $attendanceLog;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ return new class extends Migration
|
|||||||
|
|
||||||
Schema::table($tableName, function (Blueprint $table) {
|
Schema::table($tableName, function (Blueprint $table) {
|
||||||
$table->unique(['torrent', 'peer_id', 'ip']);
|
$table->unique(['torrent', 'peer_id', 'ip']);
|
||||||
|
$table->index('peer_id');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$sql = "update attendance,attendance_logs set attendance.total_days = attendance.total_days + (select count(*) from attendance_logs where uid = attendance.uid and is_retroactive = 1)";
|
||||||
|
\Illuminate\Support\Facades\DB::update($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -2553,12 +2553,12 @@ else {
|
|||||||
//// check every 60 seconds //////////////////
|
//// check every 60 seconds //////////////////
|
||||||
$activeseed = $Cache->get_value('user_'.$CURUSER["id"].'_active_seed_count');
|
$activeseed = $Cache->get_value('user_'.$CURUSER["id"].'_active_seed_count');
|
||||||
if ($activeseed == ""){
|
if ($activeseed == ""){
|
||||||
$activeseed = get_row_count("peers","WHERE userid=" . sqlesc($CURUSER["id"]) . " AND seeder='yes'");
|
$activeseed = count_peer(sprintf("userid = %s and seeder = 'yes'", $CURUSER['id']));
|
||||||
$Cache->cache_value('user_'.$CURUSER["id"].'_active_seed_count', $activeseed, 60);
|
$Cache->cache_value('user_'.$CURUSER["id"].'_active_seed_count', $activeseed, 60);
|
||||||
}
|
}
|
||||||
$activeleech = $Cache->get_value('user_'.$CURUSER["id"].'_active_leech_count');
|
$activeleech = $Cache->get_value('user_'.$CURUSER["id"].'_active_leech_count');
|
||||||
if ($activeleech == ""){
|
if ($activeleech == ""){
|
||||||
$activeleech = get_row_count("peers","WHERE userid=" . sqlesc($CURUSER["id"]) . " AND seeder='no'");
|
$activeleech = count_peer(sprintf("userid = %s and seeder = 'no'", $CURUSER['id']));
|
||||||
$Cache->cache_value('user_'.$CURUSER["id"].'_active_leech_count', $activeleech, 60);
|
$Cache->cache_value('user_'.$CURUSER["id"].'_active_leech_count', $activeleech, 60);
|
||||||
}
|
}
|
||||||
$unread = $Cache->get_value('user_'.$CURUSER["id"].'_unread_message_count');
|
$unread = $Cache->get_value('user_'.$CURUSER["id"].'_unread_message_count');
|
||||||
|
|||||||
@@ -704,3 +704,22 @@ function isIPV6 ($ip)
|
|||||||
{
|
{
|
||||||
return filter_var($ip,FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
|
return filter_var($ip,FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function count_peer($whereStr)
|
||||||
|
{
|
||||||
|
if (empty($whereStr)) {
|
||||||
|
throw new \InvalidArgumentException("require whereStr");
|
||||||
|
}
|
||||||
|
if (IN_NEXUS) {
|
||||||
|
$sql = "select count(distinct(peer_id)) as counts from peers where $whereStr";
|
||||||
|
$res = sql_query($sql);
|
||||||
|
$count = mysql_fetch_assoc($res);
|
||||||
|
return $count['counts'];
|
||||||
|
} else {
|
||||||
|
$res = \Illuminate\Support\Facades\DB::table('peers')
|
||||||
|
->whereRaw($whereStr)
|
||||||
|
->selectRaw("count(distinct(peer_id)) as counts")
|
||||||
|
->first();
|
||||||
|
return $res->counts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ switch ($type)
|
|||||||
// Current Seeding
|
// Current Seeding
|
||||||
case 'seeding':
|
case 'seeding':
|
||||||
{
|
{
|
||||||
$res = sql_query("SELECT torrent,added,snatched.uploaded,snatched.downloaded,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, categories.name as catname,size,torrents.hr,image,category,seeders,leechers FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='yes' ORDER BY torrents.added DESC") or sqlerr();
|
$res = sql_query("SELECT torrent,added,snatched.uploaded,snatched.downloaded,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, categories.name as catname,size,torrents.hr,image,category,seeders,leechers FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='yes' group by peers.peer_id ORDER BY torrents.added DESC") or sqlerr();
|
||||||
$count = mysql_num_rows($res);
|
$count = mysql_num_rows($res);
|
||||||
if ($count > 0){
|
if ($count > 0){
|
||||||
list($torrentlist, $total_size) = maketable ( $res, 'seeding' );
|
list($torrentlist, $total_size) = maketable ( $res, 'seeding' );
|
||||||
@@ -206,7 +206,7 @@ switch ($type)
|
|||||||
// Current Leeching
|
// Current Leeching
|
||||||
case 'leeching':
|
case 'leeching':
|
||||||
{
|
{
|
||||||
$res = sql_query("SELECT torrent,snatched.uploaded,snatched.downloaded,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, categories.name as catname,size,torrents.hr,image,category,seeders,leechers FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='no' ORDER BY torrents.added DESC") or sqlerr();
|
$res = sql_query("SELECT torrent,snatched.uploaded,snatched.downloaded,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, categories.name as catname,size,torrents.hr,image,category,seeders,leechers FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='no' group by peers.peer_id ORDER BY torrents.added DESC") or sqlerr();
|
||||||
$count = mysql_num_rows($res);
|
$count = mysql_num_rows($res);
|
||||||
if ($count > 0){
|
if ($count > 0){
|
||||||
list($torrentlist, $total_size) = maketable ( $res, 'leeching' );
|
list($torrentlist, $total_size) = maketable ( $res, 'leeching' );
|
||||||
|
|||||||
Reference in New Issue
Block a user