fix claim get create at last month

This commit is contained in:
xiaomlove
2023-07-04 01:00:02 +08:00
parent b951fda138
commit f5616f9979
5 changed files with 59 additions and 4 deletions
+7 -2
View File
@@ -168,10 +168,15 @@ class ClaimRepository extends BaseRepository
do_log("uid: $uid, filter: user_has_role_work_seeding => true, skip"); do_log("uid: $uid, filter: user_has_role_work_seeding => true, skip");
return false; return false;
} }
$user = User::query()->with('language')->findOrFail($uid);
$list = Claim::query()->where('uid', $uid)->with(['snatch', 'torrent' => fn ($query) => $query->select(Torrent::$commentFields)])->get();
$now = Carbon::now(); $now = Carbon::now();
$startOfThisMonth = $now->clone()->startOfMonth(); $startOfThisMonth = $now->clone()->startOfMonth();
$user = User::query()->with('language')->findOrFail($uid);
$list = Claim::query()
->where('uid', $uid)
->where("created_at", "<", $startOfThisMonth)
->with(['snatch', 'torrent' => fn ($query) => $query->select(Torrent::$commentFields)])
->get()
;
$seedTimeRequiredHours = Claim::getConfigStandardSeedTimeHours(); $seedTimeRequiredHours = Claim::getConfigStandardSeedTimeHours();
$uploadedRequiredTimes = Claim::getConfigStandardUploadedTimes(); $uploadedRequiredTimes = Claim::getConfigStandardUploadedTimes();
$bonusMultiplier = Claim::getConfigBonusMultiplier(); $bonusMultiplier = Claim::getConfigBonusMultiplier();
+1 -1
View File
@@ -5371,7 +5371,7 @@ function checkGuestVisit()
} }
function render($view, $data, $return = false) function render($view, $data = [], $return = false)
{ {
extract($data); extract($data);
if (!file_exists($view)) { if (!file_exists($view)) {
+7
View File
@@ -37,4 +37,11 @@ abstract class BasePlugin extends BaseRepository
)); ));
} }
} }
public function getNexusView($name): string
{
$reflection = new \ReflectionClass(get_called_class());
$pluginRoot = dirname($reflection->getFileName(), 2);
return $pluginRoot . "/resources/views/" . trim($name, "/");
}
} }
+15 -1
View File
@@ -5,6 +5,8 @@ class Plugin
{ {
private static mixed $providers = null; private static mixed $providers = null;
private static array $plugins = [];
public function __construct() public function __construct()
{ {
$this->loadProviders(); $this->loadProviders();
@@ -16,6 +18,11 @@ class Plugin
return !empty(self::$providers[$name]['providers']); return !empty(self::$providers[$name]['providers']);
} }
public static function getById($id) :BasePlugin|null
{
return self::$plugins[$id] ?? null;
}
public function getMainClass($name) public function getMainClass($name)
{ {
if (isset(self::$providers[$name]['providers'][0])) { if (isset(self::$providers[$name]['providers'][0])) {
@@ -39,7 +46,12 @@ class Plugin
if (defined($constantName) && version_compare(VERSION_NUMBER, constant($constantName), '<')) { if (defined($constantName) && version_compare(VERSION_NUMBER, constant($constantName), '<')) {
continue; continue;
} }
call_user_func([new $className, 'boot']); $plugin = new $className;
call_user_func([$plugin, 'boot']);
$pluginIdName = "$className::ID";
if (defined($pluginIdName)) {
self::$plugins[constant($pluginIdName)] = $plugin;
}
} }
} }
} }
@@ -58,4 +70,6 @@ class Plugin
} }
} }
+29
View File
@@ -0,0 +1,29 @@
<?php
require "../include/bittorrent.php";
if (!empty($_REQUEST['view'])) {
$view = trim($_REQUEST['view'], "/.");
$view = str_replace(".", "/", $view);
if (!empty($_REQUEST['plugin'])) {
$pluginId = $_REQUEST['plugin'];
$plugin = \Nexus\Plugin\Plugin::getById($pluginId);
$viewFile = $plugin->getNexusView($view);
} else {
$viewFile = ROOT_PATH . "resources/views/$view";
}
if (!str_ends_with($viewFile, ".php")) {
$viewFile .= ".php";
}
if (file_exists($viewFile)) {
require $viewFile;
} else {
$msg = "viewFile: $viewFile not exists, _REQUEST: " . json_encode($_REQUEST);
do_log($msg, "error");
throw new \RuntimeException($msg);
}
} else {
$msg = "require view parameter, _REQUEST: " . json_encode($_REQUEST);
do_log($msg, "error");
throw new \RuntimeException($msg);
}