Skip to content

Commit 55a3093

Browse files
committed
fix claim settleCronjob
1 parent 18449ff commit 55a3093

File tree

3 files changed

+51
-11
lines changed

3 files changed

+51
-11
lines changed

app/Repositories/ClaimRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function settleCronjob(): array
128128
{
129129
$startOfThisMonth = Carbon::now()->startOfMonth();
130130
$query = Claim::query()
131-
->select(['uid', 'count(*) as count'])
131+
->selectRaw("uid, count(*) as count)")
132132
->where("created_at", "<", $startOfThisMonth)
133133
->where(function (Builder $query) use ($startOfThisMonth) {
134134
$query->where('last_settle_at', '<', $startOfThisMonth)->orWhereNull('last_settle_at');
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('iplog', function (Blueprint $table) {
15+
$table->index('access');
16+
});
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*/
22+
public function down(): void
23+
{
24+
Schema::table('iplog', function (Blueprint $table) {
25+
//
26+
});
27+
}
28+
};

include/cleanup.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,28 @@ function docleanup($forceAll = 0, $printProgress = false) {
938938
printProgress($log);
939939
}
940940

941+
//delete old ip log
942+
$length = 90*86400; //90 days
943+
$until = date("Y-m-d H:i:s",(TIMENOW - $length));
944+
sql_query("DELETE FROM iplog WHERE access < ".sqlesc($until));
945+
$log = "delete old ip log";
946+
do_log($log);
947+
if ($printProgress) {
948+
printProgress($log);
949+
}
950+
951+
//delete failed jobs
952+
$length = 10*86400; //10 days
953+
$until = date("Y-m-d H:i:s",(TIMENOW - $length));
954+
sql_query("DELETE FROM failed_jobs WHERE failed_at < ".sqlesc($until));
955+
$log = "delete failed jobs";
956+
do_log($log);
957+
if ($printProgress) {
958+
printProgress($log);
959+
}
960+
961+
962+
941963
//cost too many time, migrate to schedule run command
942964
//sync to Meilisearch
943965
// $meiliRep = new \App\Repositories\MeiliSearchRepository();
@@ -1022,16 +1044,6 @@ function docleanup($forceAll = 0, $printProgress = false) {
10221044
printProgress($log);
10231045
}
10241046

1025-
//delete old ip log
1026-
$length = 365*86400; //a year
1027-
$until = date("Y-m-d H:i:s",(TIMENOW - $length));
1028-
sql_query("DELETE FROM iplog WHERE access < ".sqlesc($until));
1029-
$log = "delete old ip log";
1030-
do_log($log);
1031-
if ($printProgress) {
1032-
printProgress($log);
1033-
}
1034-
10351047
//delete old general log
10361048
$until = date("Y-m-d H:i:s",(TIMENOW - $length));
10371049
sql_query("DELETE FROM sitelog WHERE added < ".sqlesc($until)) or sqlerr(__FILE__, __LINE__);

0 commit comments

Comments
 (0)