Skip to content

Commit

Permalink
release: 0.17.1 Characinae Build Pack 1
Browse files Browse the repository at this point in the history
release: 0.17.1 Characinae Build Pack 1
  • Loading branch information
ZsgsDesign authored Oct 12, 2021
2 parents 4f00d5e + 2847426 commit 2afce4f
Show file tree
Hide file tree
Showing 38 changed files with 1,320 additions and 704 deletions.
20 changes: 11 additions & 9 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
APP_NAME=NOJ #App Name
APP_DISPLAY_NAME="NJUPT Online Judge" #Display Name
APP_ENV=local #Current Environment Name
APP_KEY=base64:6KvSj1hj/VJCNXnHECU16OVbcHk7h20O5TbsyOz5WuA= #App Key
APP_DEBUG=true #Debug Mode
APP_URL=http://ojsystem.com
APP_NAME=NOJ # App Name
APP_DISPLAY_NAME="NJUPT Online Judge" # Display Name
APP_ENV=local # Current Environment Name
APP_KEY=base64:6KvSj1hj/VJCNXnHECU16OVbcHk7h20O5TbsyOz5WuA= # App Key
APP_DEBUG=true # Debug Mode
APP_URL=http://ojsystem.com # APP URL
APP_MULTI_DOMAIN=true # Multi Domain Mode, Automatic match APP_URL, note that you still need to set APP_URL for console command proper running
APP_LOCALE=en
APP_LOCALE=en # APP Locale, use zh-CN for simplified chinese
APP_BACKUP=false #Enable Scheduling Backup
APP_LOGO="" #URL for site logo
APP_LOGO="/favicon.png" # URL for site logo
APP_NAVICON="/static/img/icon/icon-white.png" # URL for site nav logo
APP_FAVICON="/favicon.png" # URL for site favicon, must be png
APP_DESC=
APP_THEME="default" # choose from https://njuptaaa.github.io/docs/#/noj/guide/theme
APP_DEFAULT_EDITOR_THEME="material-design-darker" # Set to "vs-dark" uf you want classic appearance
APP_DEFAULT_EDITOR_THEME="material-design-darker" # Set to "vs-dark" if you want classic appearance
APP_ALLOW_OAUTH_TEMP_ACCOUNT=false

ADMIN_HTTPS=false
Expand Down
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,35 @@

All notable changes to this project will be documented in this file.

## NOJ 0.17.1 Characinae Build Pack 1 - 2021-10-12
This is a build version update for `0.17.0 Characinae`.

**Important:** Rerun scheduling for update site rank or run `php artisan scheduling:updateSiteRank` after this upgrade.

### Update Logs
* **Compatibility:** The update site rank scheduling is now set at 1 am everyday.
* **New:** Add custom favicon, logo, and navicon support per #737 requests.
* **New:** Add `LikeScope` trait support.
* **New:** Add dynamic rank feature, see #649.
* **New:** Add a series of artisan commands with prefix `scheduling`, see #743.
* **Deprecated:** NOJ no longer uses old `RankModel` and `SiteMapModel`.
* **Fixed:** A bug causing Admin Portal ajax pagination returns only the first 15 records, see #738.
* **Fixed:** A bug causing Admin Portal ajax pagination memory overflows on a large amount of data and queries slowly, see #739.
* **Fixed:** A bug causing PDF generator cannot locate dejaVu font.
* **Fixed:** A Symphony 5 compatibility bug causing anti-cheat malfunction, see #740.
* **Fixed:** A Symphony 5 compatibility bug causing PDF generation malfunction, see #741.
* **Fixed:** A `laravel-admin-ext/scheduling` bug causing Admin Portal schedule running returns 419 on Windows platform, see laravel-admin-extensions/scheduling#20.
* **Fixed:** Typo (only 1 this time).
* **Improved:** Optimized site rank calculation performance, see #649.
* **Improved:** Optimized sitemap performance to process a tremendous amount of data, see #742
* **Improved:** Use artisan commands for the scheduling system, see #743.
* **Improved:** Use dot-separated router for problem and status index.
* **Security:** `doctrine/dbal` is now at `2.13.4`.
* **Security:** `facade/ignition` is now at `2.15.0`.
* **Security:** `laravel-admin-ext/log-viewer` is now at `1.0.4`.
* **Security:** `laravel-admin-ext/scheduling` is now at `1.2`.
* **Security:** `ramsey/collection` is now at `1.2.2`.

## v0.17.0 Characinae - 2021-10-09
This is a minor version update. As mentioned in `0.5.0` logs, the new version system would merge the old major and minor version numbers into new minor version numbers, thus as the 17th minor version update since NOJ `0.1.0`, this version would be numbered as major version `0`, minor version `17`, build pack `0` and patch number `0`.

Expand Down
15 changes: 6 additions & 9 deletions app/Admin/Controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@

class ApiController extends AdminController
{
protected function paginate($items, $perPage = 15, $pageStart = 1)
protected function paginate($items, $perPage = 15)
{
$offSet = ($pageStart * $perPage) - $perPage;
$currentPage = Paginator::resolveCurrentPage();
$offSet = ($currentPage * $perPage) - $perPage;
$itemsForCurrentPage = array_slice($items, $offSet, $perPage, true);
$paginator = new LengthAwarePaginator($itemsForCurrentPage, count($items), $perPage, Paginator::resolveCurrentPage(), ['path' => Paginator::resolveCurrentPath()]);
$paginator = new LengthAwarePaginator($itemsForCurrentPage, count($items), $perPage, $currentPage, ['path' => Paginator::resolveCurrentPath()]);
return $paginator;
}

public function problems()
{
$q = request()->q;

return $this->paginate(Problem::orderBy('pcode', 'asc')->get()->filter(function ($problem) use ($q) {
return stripos($problem->readable_name, $q) !== false;
})->values()->transform(function ($problem) {
return $this->paginate(Problem::like('pcode', $q)->orLike('title', $q)->orderBy('pcode', 'asc')->get()->values()->transform(function ($problem) {
return [
'id' => $problem->pid,
'text' => $problem->readable_name,
Expand All @@ -36,9 +35,7 @@ public function users()
{
$q = request()->q;

return $this->paginate(User::get()->filter(function ($user) use ($q) {
return stripos($user->readable_name, $q) !== false;
})->values()->transform(function ($user) {
return $this->paginate(User::like('name', $q)->orLike('email', $q)->orderBy('id', 'asc')->get()->values()->transform(function ($user) {
return [
'id' => $user->id,
'text' => $user->readable_name,
Expand Down
4 changes: 2 additions & 2 deletions app/Admin/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Encore\Admin\Admin;
use Encore\Admin\Facades\Admin;

/**
* Laravel-admin - admin builder based on Laravel.
Expand All @@ -25,7 +25,7 @@
Admin::css('/static/fonts/poppins/poppins.css?version=1.0.0');
Admin::style(".main-sidebar, .main-footer, .main-header .logo .logo-lg, h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {font-family:'Poppins';}");
Admin::js(mix('/static/js/build/app.admin.js'));
Admin::favicon('/favicon.png');
Admin::favicon(config('app.favicon'));
Encore\Admin\Form::forget(['map', 'editor']);
Encore\Admin\Form::extend('chunk_file', \Encore\ChunkFileUpload\ChunkFileField::class);
app('view')->prependNamespace('admin', resource_path('views/admin'));
Expand Down
67 changes: 67 additions & 0 deletions app/Console/Commands/Scheduling/SyncContestProblem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace App\Console\Commands\Scheduling;

use Illuminate\Console\Command;
use App\Models\ContestModel;
use Carbon;

class SyncContestProblem extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature='scheduling:syncContestProblem';

/**
* The console command description.
*
* @var string
*/
protected $description='Scheduling for remote contest problem sync';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$time=Carbon::now();
$this->line("<fg=yellow>[$time] Processing: </>Sync Remote Contest Problem");

$contestModel=new ContestModel();
$syncList=$contestModel->runningContest();
foreach ($syncList as $syncContest) {
if (isset($syncContest['crawled'])) {
if (!$syncContest['crawled']) {
$className="App\\Babel\\Extension\\hdu\\Synchronizer";
$all_data=[
'oj'=>"hdu",
'vcid'=>$syncContest['vcid'],
'gid'=>$syncContest['gid'],
'cid'=>$syncContest['cid'],
];
$hduSync=new $className($all_data);
$hduSync->scheduleCrawl();
$contestModel->updateCrawlStatus($syncContest['cid']);
}
}
}

$time=Carbon::now();
$this->line("<fg=green>[$time] Processed: </>Successfully Synced Remote Contest Problem");
}
}
73 changes: 73 additions & 0 deletions app/Console/Commands/Scheduling/SyncRankClarification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace App\Console\Commands\Scheduling;

use Illuminate\Console\Command;
use App\Models\ContestModel;
use App\Models\Eloquent\Contest;
use Cache;
use Carbon;

class SyncRankClarification extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature='scheduling:syncRankClarification';

/**
* The console command description.
*
* @var string
*/
protected $description='Scheduling for remote rank and clarification sync';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$time=Carbon::now();
$this->line("<fg=yellow>[$time] Processing: </>Sync Remote Contest Rank and Clarification");

$contestModel=new ContestModel();
$syncList=$contestModel->runningContest();
foreach ($syncList as $syncContest) {
if (!isset($syncContest['vcid'])) {
$contest=Contest::find($syncContest['cid']);
$contestRankRaw=$contest->rankRefresh();
$cid=$syncContest['cid'];
Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw);
Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw);
continue;
}
$className="App\\Babel\\Extension\\hdu\\Synchronizer"; // TODO Add OJ judgement.
$all_data=[
'oj'=>"hdu",
'vcid'=>$syncContest['vcid'],
'gid'=>$syncContest['gid'],
'cid'=>$syncContest['cid'],
];
$hduSync=new $className($all_data);
$hduSync->crawlRank();
$hduSync->crawlClarification();
}

$time=Carbon::now();
$this->line("<fg=green>[$time] Processed: </>Successfully Synced Remote Contest Rank and Clarification");
}
}
69 changes: 69 additions & 0 deletions app/Console/Commands/Scheduling/UpdateGroupElo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace App\Console\Commands\Scheduling;

use Illuminate\Console\Command;
use App\Models\GroupModel;
use Carbon;
use Log;

class UpdateGroupElo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature='scheduling:updateGroupElo';

/**
* The console command description.
*
* @var string
*/
protected $description='Scheduling for group elo update';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$time=Carbon::now();
$this->line("<fg=yellow>[$time] Processing: </>Update Group Elo");

$groupModel=new GroupModel();
$ret=$groupModel->refreshAllElo();
foreach ($ret as $gid => $group) {
if (empty($group['result'])) {
Log::channel('group_elo')->info('Refreshed Group Elo (Empty) : ('.$gid.')'.$group['name']);
} else {
Log::channel('group_elo')->info('Refreshing Group Elo: ('.$gid.')'.$group['name']);
foreach ($group['result'] as $contest) {
if ($contest['ret']=='success') {
Log::channel('group_elo')->info(' Elo Clac Successfully : ('.$contest['cid'].')'.$contest['name']);
} else {
Log::channel('group_elo')->info(' Elo Clac Faild (Judge Not Over) : ('.$contest['cid'].')'.$contest['name'].' sids:');
foreach ($contest['submissions'] as $sid) {
Log::channel('group_elo')->info(' '.$sid['sid']);
}
}
}
}
}

$time=Carbon::now();
$this->line("<fg=green>[$time] Processed: </>Successfully Updated Group Elo");
}
}
64 changes: 64 additions & 0 deletions app/Console/Commands/Scheduling/UpdateJudgeServerStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace App\Console\Commands\Scheduling;

use Illuminate\Console\Command;
use App\Models\Eloquent\JudgeServer;
use App\Models\Eloquent\OJ;
use App\Babel\Babel;
use Carbon;
use Exception;
use Log;

class UpdateJudgeServerStatus extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature='scheduling:updateJudgeServerStatus';

/**
* The console command description.
*
* @var string
*/
protected $description='Scheduling for JudgeServer status update';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$time=Carbon::now();
$this->line("<fg=yellow>[$time] Processing: </>Update JudgeServer Status");

$platformIDs=JudgeServer::column('oid');
$babel=new Babel();
foreach ($platformIDs as $platform) {
try {
$babel->monitor([
"name" => OJ::findOrFail($platform)->ocode
]);
} catch (Exception $e) {
Log::alert("Moniting OID $platform Failed.\n".$e->getMessage());
}
}

$time=Carbon::now();
$this->line("<fg=green>[$time] Processed: </>Successfully Updated JudgeServer Status");
}
}
Loading

0 comments on commit 2afce4f

Please sign in to comment.