mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 13:28:41 +00:00
refactor(web/contest): remove UOJContest::queryContestsHasProblem()
use UOJProblem::findInContests() instead.
This commit is contained in:
parent
738b819b5f
commit
8d87fda233
@ -38,11 +38,10 @@ class UOJBlog {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($problem_id = $this->getSolutionProblemId()) {
|
||||
$contests = UOJContest::queryContestsHasProblem(UOJProblem::query($problem_id));
|
||||
|
||||
foreach ($contests as $contest) {
|
||||
if ($contest->userHasRegistered($user) && $contest->progress() == CONTEST_IN_PROGRESS) {
|
||||
$problem = $this->getSolutionProblem();
|
||||
if ($problem) {
|
||||
foreach ($problem->findInContests() as $cp) {
|
||||
if ($cp->contest->userHasRegistered($user) && $cp->contest->progress() == CONTEST_IN_PROGRESS) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -218,6 +217,15 @@ class UOJBlog {
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function getSolutionProblem() {
|
||||
return UOJProblem::query(DB::selectSingle([
|
||||
DB::lc(), "select 1 from problems_solutions",
|
||||
"where", [
|
||||
"blog_id" => $this->info['id'],
|
||||
],
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
UOJBlog::$table_for_content = 'blogs';
|
||||
|
@ -28,16 +28,6 @@ class UOJContest {
|
||||
]));
|
||||
}
|
||||
|
||||
public static function queryContestsHasProblem(UOJProblem $problem) {
|
||||
return array_map(fn ($x) => UOJContest::query($x['contest_id']), DB::selectAll([
|
||||
"select contest_id from contests_problems",
|
||||
"where", [
|
||||
"problem_id" => $problem->info['id'],
|
||||
],
|
||||
"order by contest_id",
|
||||
]));
|
||||
}
|
||||
|
||||
public static function userCanManageSomeContest(array $user = null) {
|
||||
if (!$user) {
|
||||
return false;
|
||||
|
@ -289,10 +289,8 @@ class UOJProblem {
|
||||
return false;
|
||||
}
|
||||
|
||||
$contests = UOJContest::queryContestsHasProblem($this);
|
||||
|
||||
foreach ($contests as $contest) {
|
||||
if ($contest->userHasRegistered($user) && $contest->progress() <= CONTEST_IN_PROGRESS) {
|
||||
foreach ($this->findInContests() as $cp) {
|
||||
if ($cp->contest->userHasRegistered($user) && $cp->contest->progress() == CONTEST_IN_PROGRESS) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -326,12 +324,10 @@ class UOJProblem {
|
||||
}
|
||||
|
||||
public function additionalSubmissionComponentsCannotBeSeenByUser(array $user = null, UOJSubmission $submission) {
|
||||
$contests = UOJContest::queryContestsHasProblem($this);
|
||||
|
||||
foreach ($contests as $contest) {
|
||||
if ($contest->userHasRegistered($user) && $contest->progress() == CONTEST_IN_PROGRESS) {
|
||||
foreach ($this->findInContests() as $cp) {
|
||||
if ($cp->contest->userHasRegistered($user) && $cp->contest->progress() == CONTEST_IN_PROGRESS) {
|
||||
if ($submission->userIsSubmitter($user)) {
|
||||
if ($contest->getJudgeTypeInContest() == 'no-details') {
|
||||
if ($cp->contest->getJudgeTypeInContest() == 'no-details') {
|
||||
return ['low_level_details'];
|
||||
} else {
|
||||
return [];
|
||||
|
Loading…
Reference in New Issue
Block a user