mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-20 17:37:23 +08:00
update: add attendance migrate
This commit is contained in:
@@ -53,32 +53,7 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$page = 1;
|
||||
$size = 1000;
|
||||
while (true) {
|
||||
$logPrefix = "[MIGRATE_ATTENDANCE], page: $page, size: $size";
|
||||
$result = Attendance::query()
|
||||
->groupBy(['uid'])
|
||||
->selectRaw('uid, max(id) as id, count(*) as counts')
|
||||
->forPage($page, $size)
|
||||
->get();
|
||||
do_log("$logPrefix, " . last_query() . ", count: " . $result->count());
|
||||
if ($result->isEmpty()) {
|
||||
do_log("$logPrefix, no more data...");
|
||||
break;
|
||||
}
|
||||
foreach ($result as $row) {
|
||||
$update = [
|
||||
'total_days' => $row->counts,
|
||||
];
|
||||
$updateResult = $row->update($update);
|
||||
do_log(sprintf(
|
||||
"$logPrefix, update user: %s(ID: %s) => %s, result: %s",
|
||||
$row->uid, $row->id, json_encode($update), var_export($updateResult, true)
|
||||
));
|
||||
}
|
||||
$page++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2476,7 +2476,7 @@ else {
|
||||
<?php if (get_user_class() >= UC_SYSOP) { ?> [<a href="settings.php"><?php echo $lang_functions['text_site_settings'] ?></a>]<?php } ?>
|
||||
[<a href="torrents.php?inclbookmarked=1&allsec=1&incldead=0"><?php echo $lang_functions['text_bookmarks'] ?></a>]
|
||||
<font class = 'color_bonus'><?php echo $lang_functions['text_bonus'] ?></font>[<a href="mybonus.php"><?php echo $lang_functions['text_use'] ?></a>]: <?php echo number_format($CURUSER['seedbonus'], 1)?>
|
||||
<?php if($attendance){ printf(' '.$lang_functions['text_attended'], $attendance['total_points']); }else{ printf(' <a href="attendance.php" class="faqlink">%s</a>', $lang_functions['text_attendance']);}?>
|
||||
<?php if($attendance){ printf(' '.$lang_functions['text_attended'], $attendance['points']); }else{ printf(' <a href="attendance.php" class="faqlink">%s</a>', $lang_functions['text_attendance']);}?>
|
||||
<font class = 'color_invite'><?php echo $lang_functions['text_invite'] ?></font>[<a href="invite.php?id=<?php echo $CURUSER['id']?>"><?php echo $lang_functions['text_send'] ?></a>]: <?php echo $CURUSER['invites']?><br />
|
||||
<font class="color_ratio"><?php echo $lang_functions['text_ratio'] ?></font> <?php echo $ratio?>
|
||||
<font class='color_uploaded'><?php echo $lang_functions['text_uploaded'] ?></font> <?php echo mksize($CURUSER['uploaded'])?>
|
||||
|
||||
@@ -107,8 +107,8 @@ class Update extends Install
|
||||
*
|
||||
* attendance change, do migrate
|
||||
*/
|
||||
if (WITH_LARAVEL && VERSION_NUMBER == '1.6.0-beta9' && NexusDB::schema()->hasColumn('attendance', 'total_points')) {
|
||||
|
||||
if (WITH_LARAVEL && VERSION_NUMBER == '1.6.0-beta9' && NexusDB::schema()->hasColumn('attendance', 'total_days')) {
|
||||
$this->migrateAttendance();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,13 +116,11 @@ class Update extends Install
|
||||
{
|
||||
$page = 1;
|
||||
$size = 1000;
|
||||
$sub = Attendance::query()->orderBy('id', 'desc');
|
||||
while (true) {
|
||||
$logPrefix = "[MIGRATE_ATTENDANCE], page: $page, size: $size";
|
||||
$result = Attendance::query()
|
||||
->fromSub($sub, 'a')
|
||||
->groupBy('id, uid')
|
||||
->selectRaw('id, uid, count(*) as counts')
|
||||
->groupBy(['uid'])
|
||||
->selectRaw('uid, max(id) as id, count(*) as counts')
|
||||
->forPage($page, $size)
|
||||
->get();
|
||||
$this->doLog("$logPrefix, " . last_query() . ", count: " . $result->count());
|
||||
@@ -136,7 +134,7 @@ class Update extends Install
|
||||
];
|
||||
$updateResult = $row->update($update);
|
||||
$this->doLog(sprintf(
|
||||
"$logPrefix, update user: %s(%s) => %s, result: %s",
|
||||
"$logPrefix, update user: %s(ID: %s) => %s, result: %s",
|
||||
$row->uid, $row->id, json_encode($update), var_export($updateResult, true)
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user