mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 03:08:41 +00:00
chore: add upgrader for #39.
This commit is contained in:
parent
83da060ec6
commit
be6dd872b7
@ -13,7 +13,7 @@ function requireLib($name) { // html lib
|
|||||||
$REQUIRE_LIB[$name] = '';
|
$REQUIRE_LIB[$name] = '';
|
||||||
}
|
}
|
||||||
function requirePHPLib($name) { // uoj php lib
|
function requirePHPLib($name) { // uoj php lib
|
||||||
require $_SERVER['DOCUMENT_ROOT'] . '/app/libs/uoj-' . $name . '-lib.php';
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/app/libs/uoj-' . $name . '-lib.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
requirePHPLib('expection');
|
requirePHPLib('expection');
|
||||||
|
37
web/app/upgrade/39_limits_in_extra_config/upgrade.php
Normal file
37
web/app/upgrade/39_limits_in_extra_config/upgrade.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
requirePHPLib('data');
|
||||||
|
|
||||||
|
return function ($type) {
|
||||||
|
if ($type == 'up') {
|
||||||
|
DB::init();
|
||||||
|
|
||||||
|
$problems = DB::selectAll("select * from problems");
|
||||||
|
|
||||||
|
foreach ($problems as $info) {
|
||||||
|
$problem = new UOJProblem($info);
|
||||||
|
|
||||||
|
$extra_config = $problem->getExtraConfig();
|
||||||
|
$problem_conf = $problem->getProblemConf();
|
||||||
|
|
||||||
|
if (!($problem_conf instanceof UOJProblemConf)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$extra_config['time_limit'] = (float)$problem_conf->getVal('time_limit', 1);
|
||||||
|
$extra_config['memory_limit'] = (int)$problem_conf->getVal('memory_limit', 256);
|
||||||
|
|
||||||
|
DB::update([
|
||||||
|
"update problems",
|
||||||
|
"set", [
|
||||||
|
"extra_config" => json_encode($extra_config, JSON_FORCE_OBJECT),
|
||||||
|
],
|
||||||
|
"where", [
|
||||||
|
"id" => $problem->info['id'],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
echo "Problem {$problem->info['id']} upgraded.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user