fix claim settleCronjob

This commit is contained in:
xiaomlove
2025-05-13 17:26:03 +07:00
parent 18449ff185
commit 55a30939dd
3 changed files with 51 additions and 11 deletions

View File

@@ -128,7 +128,7 @@ class ClaimRepository extends BaseRepository
{
$startOfThisMonth = Carbon::now()->startOfMonth();
$query = Claim::query()
->select(['uid', 'count(*) as count'])
->selectRaw("uid, count(*) as count)")
->where("created_at", "<", $startOfThisMonth)
->where(function (Builder $query) use ($startOfThisMonth) {
$query->where('last_settle_at', '<', $startOfThisMonth)->orWhereNull('last_settle_at');

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('iplog', function (Blueprint $table) {
$table->index('access');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('iplog', function (Blueprint $table) {
//
});
}
};

View File

@@ -938,6 +938,28 @@ function docleanup($forceAll = 0, $printProgress = false) {
printProgress($log);
}
//delete old ip log
$length = 90*86400; //90 days
$until = date("Y-m-d H:i:s",(TIMENOW - $length));
sql_query("DELETE FROM iplog WHERE access < ".sqlesc($until));
$log = "delete old ip log";
do_log($log);
if ($printProgress) {
printProgress($log);
}
//delete failed jobs
$length = 10*86400; //10 days
$until = date("Y-m-d H:i:s",(TIMENOW - $length));
sql_query("DELETE FROM failed_jobs WHERE failed_at < ".sqlesc($until));
$log = "delete failed jobs";
do_log($log);
if ($printProgress) {
printProgress($log);
}
//cost too many time, migrate to schedule run command
//sync to Meilisearch
// $meiliRep = new \App\Repositories\MeiliSearchRepository();
@@ -1022,16 +1044,6 @@ function docleanup($forceAll = 0, $printProgress = false) {
printProgress($log);
}
//delete old ip log
$length = 365*86400; //a year
$until = date("Y-m-d H:i:s",(TIMENOW - $length));
sql_query("DELETE FROM iplog WHERE access < ".sqlesc($until));
$log = "delete old ip log";
do_log($log);
if ($printProgress) {
printProgress($log);
}
//delete old general log
$until = date("Y-m-d H:i:s",(TIMENOW - $length));
sql_query("DELETE FROM sitelog WHERE added < ".sqlesc($until)) or sqlerr(__FILE__, __LINE__);