mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
attendance card
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Attendance;
|
||||
use App\Repositories\AttendanceRepository;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class AttendanceCleanup extends Command
|
||||
@@ -33,39 +34,16 @@ class AttendanceCleanup extends Command
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$query = Attendance::query()->groupBy('uid')->selectRaw('uid, max(id) as max_id');
|
||||
$page = 1;
|
||||
$size = 10000;
|
||||
while (true) {
|
||||
$rows = $query->forPage($page, $size)->get();
|
||||
$log = "sql: " . last_query() . ", count: " . $rows->count();
|
||||
do_log($log);
|
||||
$this->info($log);
|
||||
if ($rows->isEmpty()) {
|
||||
$log = "no more data....";
|
||||
do_log($log);
|
||||
$this->info($log);
|
||||
break;
|
||||
}
|
||||
foreach ($rows as $row) {
|
||||
do {
|
||||
$deleted = Attendance::query()
|
||||
->where('uid', $row->uid)
|
||||
->where('id', '<', $row->max_id)
|
||||
->limit(10000)
|
||||
->delete();
|
||||
$log = "delete: $deleted by sql: " . last_query();
|
||||
do_log($log);
|
||||
$this->info($log);
|
||||
} while ($deleted > 0);
|
||||
}
|
||||
$page++;
|
||||
}
|
||||
return 0;
|
||||
$rep = new AttendanceRepository();
|
||||
$result = $rep->cleanup();
|
||||
$log = sprintf(
|
||||
'[%s], %s, result: %s',
|
||||
nexus()->getRequestId(), __METHOD__, var_export($result, true)
|
||||
);
|
||||
$this->info($log);
|
||||
do_log($log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,21 +70,21 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$searchRep = new SearchRepository();
|
||||
$r = $searchRep->deleteIndex();
|
||||
$r = $searchRep->createIndex();
|
||||
$r = $searchRep->import();
|
||||
|
||||
$arr = [
|
||||
'cat' => 'category',
|
||||
'source' => 'source',
|
||||
'medium' => 'medium',
|
||||
'codec' => 'codec',
|
||||
'audiocodec' => 'audiocodec',
|
||||
'standard' => 'standard',
|
||||
'processing' => 'processing',
|
||||
'team' => 'team',
|
||||
];
|
||||
// $searchRep = new SearchRepository();
|
||||
// $r = $searchRep->deleteIndex();
|
||||
// $r = $searchRep->createIndex();
|
||||
// $r = $searchRep->import();
|
||||
//
|
||||
// $arr = [
|
||||
// 'cat' => 'category',
|
||||
// 'source' => 'source',
|
||||
// 'medium' => 'medium',
|
||||
// 'codec' => 'codec',
|
||||
// 'audiocodec' => 'audiocodec',
|
||||
// 'standard' => 'standard',
|
||||
// 'processing' => 'processing',
|
||||
// 'team' => 'team',
|
||||
// ];
|
||||
$queryString = 'cat401=1&cat404=1&source2=1&medium2=1&medium3=1&codec3=1&audiocodec3=1&standard2=1&standard3=1&processing2=1&team3=1&team4=1&incldead=1&spstate=0&inclbookmarked=0&search=&search_area=0&search_mode=0';
|
||||
$userSetting = '[cat401][cat404][sou1][med1][cod1][sta2][sta3][pro2][tea2][aud2][incldead=0][spstate=3][inclbookmarked=2]';
|
||||
// foreach ($arr as $queryField => $value) {
|
||||
@@ -116,6 +116,11 @@ class Test extends Command
|
||||
// $r = $searchRep->deleteBookmark(1);
|
||||
// $r = $searchRep->addBookmark(1);
|
||||
|
||||
$rep = new AttendanceRepository();
|
||||
$uid = 1;
|
||||
$attendance = $rep->getAttendance($uid);
|
||||
// $r = $rep->migrateAttendanceLogs($uid);
|
||||
$r = $rep->getContinuousDays($attendance);
|
||||
dd($r);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user