add seed bonus + seed time update time

This commit is contained in:
xiaomlove
2022-11-23 17:34:45 +08:00
parent 93d41352c4
commit 05f8b2e0b4
10 changed files with 1636 additions and 548 deletions
+2 -1
View File
@@ -94,7 +94,8 @@ class CalculateUserSeedBonus implements ShouldQueue
$dividend = 3600 / $autoclean_interval_one; $dividend = 3600 / $autoclean_interval_one;
$all_bonus = $all_bonus / $dividend; $all_bonus = $all_bonus / $dividend;
$seed_points = $seedBonusResult['seed_points'] / $dividend; $seed_points = $seedBonusResult['seed_points'] / $dividend;
$sql = "update users set seed_points = ifnull(seed_points, 0) + $seed_points, seedbonus = seedbonus + $all_bonus where id = $uid limit 1"; $updatedAt = now()->toDateTimeString();
$sql = "update users set seed_points = ifnull(seed_points, 0) + $seed_points, seedbonus = seedbonus + $all_bonus, seed_points_updated_at = '$updatedAt' where id = $uid limit 1";
do_log("$bonusLog, query: $sql"); do_log("$bonusLog, query: $sql");
NexusDB::statement($sql); NexusDB::statement($sql);
} }
+2 -2
View File
@@ -53,8 +53,8 @@ class UpdateUserSeedingLeechingTime implements ShouldQueue
$beginTimestamp = time(); $beginTimestamp = time();
$logPrefix = sprintf("[CLEANUP_CLI_UPDATE_SEEDING_LEECHING_TIME], commonRequestId: %s, beginUid: %s, endUid: %s", $this->requestId, $this->beginUid, $this->endUid); $logPrefix = sprintf("[CLEANUP_CLI_UPDATE_SEEDING_LEECHING_TIME], commonRequestId: %s, beginUid: %s, endUid: %s", $this->requestId, $this->beginUid, $this->endUid);
$sql = sprintf( $sql = sprintf(
"update users set seedtime = (select sum(seedtime) from snatched where userid = users.id), leechtime=(select sum(leechtime) from snatched where userid = users.id) where id > %s and id <= %s and status = 'confirmed' and enabled = 'yes'", "update users set seedtime = (select sum(seedtime) from snatched where userid = users.id), leechtime=(select sum(leechtime) from snatched where userid = users.id), seed_time_updated_at = '%s' where id > %s and id <= %s and status = 'confirmed' and enabled = 'yes'",
$this->beginUid, $this->endUid $this->beginUid, $this->endUid, now()->toDateTimeString()
); );
$results = NexusDB::statement($sql); $results = NexusDB::statement($sql);
$costTime = time() - $beginTimestamp; $costTime = time() - $beginTimestamp;
+2 -2
View File
@@ -25,17 +25,17 @@
"ext-bcmath": "*", "ext-bcmath": "*",
"ext-curl": "*", "ext-curl": "*",
"ext-gd": "*", "ext-gd": "*",
"ext-gmp": "*",
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"ext-mysqli": "*", "ext-mysqli": "*",
"ext-pcntl": "*", "ext-pcntl": "*",
"ext-redis": "*", "ext-redis": "*",
"ext-xml": "*", "ext-xml": "*",
"ext-gmp": "*",
"ext-zend-opcache": "*", "ext-zend-opcache": "*",
"doctrine/dbal": "^3.1", "doctrine/dbal": "^3.1",
"elasticsearch/elasticsearch": "^7.16", "elasticsearch/elasticsearch": "^7.16",
"filament/filament": "2.16.41", "filament/filament": "2.16.51",
"flowframe/laravel-trend": "^0.1.1", "flowframe/laravel-trend": "^0.1.1",
"fruitcake/laravel-cors": "^2.0", "fruitcake/laravel-cors": "^2.0",
"geoip2/geoip2": "~2.0", "geoip2/geoip2": "~2.0",
Generated
+1586 -538
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,33 @@
<?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()
{
Schema::table('users', function (Blueprint $table) {
$table->dateTime('seed_points_updated_at')->nullable(true);
$table->dateTime('seed_time_updated_at')->nullable(true);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('seed_points_updated_at', 'seed_time_updated_at');
});
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
<?php <?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0'); defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-11-14'); defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-11-23');
defined('IN_TRACKER') || define('IN_TRACKER', false); defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP"); defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org"); defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
+1
View File
@@ -322,6 +322,7 @@ class Update extends Install
if (empty($menus)) { if (empty($menus)) {
return; return;
} }
$this->doLog("[REMOVE MENU]: " . json_encode($menus));
foreach ($tables as $table) { foreach ($tables as $table) {
NexusDB::table($table)->whereIn('url', $menus)->delete(); NexusDB::table($table)->whereIn('url', $menus)->delete();
} }
+3 -1
View File
@@ -303,9 +303,11 @@ final class Nexus
private static function loadTranslations($path, $namespace = null) private static function loadTranslations($path, $namespace = null)
{ {
do_log("path: $path, namespace: $namespace", 'debug');
$files = glob($path . '*/*'); $files = glob($path . '*/*');
foreach ($files as $file) { foreach ($files as $file) {
if (!is_file($file)) { if (!is_file($file)) {
do_log("file: $file, is not file", 'debug');
continue; continue;
} }
if (!is_readable($file)) { if (!is_readable($file)) {
@@ -320,7 +322,7 @@ final class Nexus
if ($namespace !== null) { if ($namespace !== null) {
$setKey = "$namespace.$setKey"; $setKey = "$namespace.$setKey";
} }
// do_log("path: $path, namespace: $namespace, file: $file, setKey: $setKey", 'debug'); do_log("path: $path, namespace: $namespace, file: $file, setKey: $setKey", 'debug');
arr_set(self::$translations, $setKey, $values); arr_set(self::$translations, $setKey, $values);
} }
} }
+3
View File
@@ -64,3 +64,6 @@ img.hitandrun {
.nexus-media-info-raw pre { .nexus-media-info-raw pre {
white-space: break-spaces; white-space: break-spaces;
} }
.text-muted {
color: #7d7b7b
}
+3 -3
View File
@@ -283,7 +283,7 @@ if ($user["downloaded"] > 0 && $true_download > 0)
//end //end
$xfer = "<tr><td class=\"embedded\"><strong>" . $lang_userdetails['row_uploaded'] . "</strong>: ". mksize($user["uploaded"]) . "</td><td class=\"embedded\">&nbsp;&nbsp;<strong>" . $lang_userdetails['row_downloaded'] . "</strong>: " . mksize($user["downloaded"]) . "</td></tr>"; $xfer = "<tr><td class=\"embedded\"><strong>" . $lang_userdetails['row_uploaded'] . "</strong>: ". mksize($user["uploaded"]) . "</td><td class=\"embedded\">&nbsp;&nbsp;<strong>" . $lang_userdetails['row_downloaded'] . "</strong>: " . mksize($user["downloaded"]) . "</td></tr>";
$true_xfer = "<tr><td class=\"embedded\"><strong>" . $lang_userdetails['row_real_uploaded'] . "</strong>: ". mksize($true_upload) . "</td><td class=\"embedded\">&nbsp;&nbsp;<strong>" . $lang_userdetails['row_real_downloaded'] . "</strong>: " . mksize($true_download) . "</td><td class=\"embedded\" style=\"color: #7d7b7b;\">&nbsp;&nbsp;" . $lang_userdetails['row_real_ps'] . "</td></tr>"; $true_xfer = "<tr><td class=\"embedded\"><strong>" . $lang_userdetails['row_real_uploaded'] . "</strong>: ". mksize($true_upload) . "</td><td class=\"embedded\">&nbsp;&nbsp;<strong>" . $lang_userdetails['row_real_downloaded'] . "</strong>: " . mksize($true_download) . "</td><td class=\"embedded text-muted\">&nbsp;&nbsp;" . $lang_userdetails['row_real_ps'] . "</td></tr>";
tr_small($lang_userdetails['row_transfer'], "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" . ($sr ?? '') . $xfer . $true_xfer . "</table>", 1); tr_small($lang_userdetails['row_transfer'], "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" . ($sr ?? '') . $xfer . $true_xfer . "</table>", 1);
@@ -293,7 +293,7 @@ if ($user["leechtime"] > 0)
$slr = "<tr><td class=\"embedded\"><strong>" . $lang_userdetails['text_seeding_leeching_time_ratio'] . "</strong>: <font color=\"" . get_ratio_color($slr) . "\">" . number_format($slr, 3) . "</font></td><td class=\"embedded\">&nbsp;&nbsp;" . get_ratio_img($slr) . "</td></tr>"; $slr = "<tr><td class=\"embedded\"><strong>" . $lang_userdetails['text_seeding_leeching_time_ratio'] . "</strong>: <font color=\"" . get_ratio_color($slr) . "\">" . number_format($slr, 3) . "</font></td><td class=\"embedded\">&nbsp;&nbsp;" . get_ratio_img($slr) . "</td></tr>";
} }
$slt = "<tr><td class=\"embedded\"><strong>" . $lang_userdetails['text_seeding_time'] . "</strong>: ". mkprettytime($user["seedtime"]) . "</td><td class=\"embedded\">&nbsp;&nbsp;<strong>" . $lang_userdetails['text_leeching_time'] . "</strong>: " . mkprettytime($user["leechtime"]) . "</td></tr>"; $slt = "<tr><td class=\"embedded\"><strong>" . $lang_userdetails['text_seeding_time'] . "</strong>: ". mkprettytime($user["seedtime"]) . "</td><td class=\"embedded\">&nbsp;&nbsp;<strong>" . $lang_userdetails['text_leeching_time'] . "</strong>: " . mkprettytime($user["leechtime"]) . "</td><td class=\"embedded text-muted\">&nbsp;&nbsp;(" . nexus_trans('label.updated_at') . ": " . $user['seed_time_updated_at'] . ")</td></tr>";
tr_small($lang_userdetails['row_sltime'], "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" . ($slr ?? '') . $slt . "</table>", 1); tr_small($lang_userdetails['row_sltime'], "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" . ($slr ?? '') . $slt . "</table>", 1);
@@ -400,7 +400,7 @@ if ($user["id"] == $CURUSER["id"] || user_can('viewhistory')) {
tr_small($lang_functions['menu_claim'], sprintf('<a href="claim.php?uid=%s" target="_blank">%s</a>', $user['id'], $states), 1); tr_small($lang_functions['menu_claim'], sprintf('<a href="claim.php?uid=%s" target="_blank">%s</a>', $user['id'], $states), 1);
} }
tr_small($lang_userdetails['row_karma_points'], number_format($user['seedbonus'], 1), 1); tr_small($lang_userdetails['row_karma_points'], number_format($user['seedbonus'], 1), 1);
tr_small($lang_functions['text_seed_points'], number_format($user['seed_points'], 1), 1); tr_small($lang_functions['text_seed_points'], number_format($user['seed_points'], 1) . "&nbsp;&nbsp;<span class='text-muted'>(" . nexus_trans('label.updated_at') . ": " . $user['seed_points_updated_at'] . ")</span>", 1);
} }
if (user_can('prfmanage') && $user["class"] < get_user_class()) { if (user_can('prfmanage') && $user["class"] < get_user_class()) {