S2OJ/web/app/upgrade/14_sync_from_uoj.ac/upgrade.php
2022-11-06 10:26:36 +08:00

64 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
return function (string $type) {
if ($type == 'up_after_sql') {
DB::init();
// === 用户 ===
$users = DB::selectAll("SELECT * FROM user_info");
foreach ($users as $user) {
$extra = UOJUser::getExtra($user);
$extra['avatar_source'] = $user['avatar_source'];
$extra['social']['codeforces'] = $user['codeforces_handle'];
$extra['social']['github'] = $user['github'];
$extra['social']['website'] = $user['website'];
$extra['image_hosting']['total_size_limit'] = $user['images_size_limit'];
DB::update([
"update user_info",
"set", [
"extra" => json_encode($extra),
],
"where", [
"username" => $user['username'],
],
]);
}
DB::query("ALTER TABLE `user_info` DROP avatar_source, DROP website, DROP github, DROP codeforces_handle, DROP images_size_limit");
// === 题目 ===
$problems = DB::selectAll("SELECT * FROM `problems`");
foreach ($problems as $info) {
$problem = new UOJProblem($info);
UOJSystemUpdate::updateProblem($problem, [
'text' => '系统更新S2OJ 开始保存测评记录历史',
'url' => 'https://sjzezoj.com/blog/baoshuo/post/599',
]);
}
// === Hacks ===
$hacks = DB::selectAll([
"select * from hacks",
"order by id",
]);
foreach ($hacks as $hack) {
DB::update([
"update hacks",
"set", [
"status" => $hack['judge_time'] ? "Judged" : "Waiting",
],
"where", [
"id" => $hack['id'],
]
]);
}
}
};