attendance retroactive increment total_days

This commit is contained in:
xiaomlove
2022-04-19 02:07:30 +08:00
parent 242ddcf6ca
commit 38851fc30e
6 changed files with 60 additions and 5 deletions
+2 -2
View File
@@ -2553,12 +2553,12 @@ else {
//// check every 60 seconds //////////////////
$activeseed = $Cache->get_value('user_'.$CURUSER["id"].'_active_seed_count');
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);
}
$activeleech = $Cache->get_value('user_'.$CURUSER["id"].'_active_leech_count');
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);
}
$unread = $Cache->get_value('user_'.$CURUSER["id"].'_unread_message_count');
+19
View File
@@ -704,3 +704,22 @@ function isIPV6 ($ip)
{
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;
}
}