mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
eslint: variable naming
This commit is contained in:
1 parent
55a95b97ea
commit
268ac23b26
17 files changed
+96
-52
No files matched your search
@@ -49,13 +49,13 @@ async function syzojSync(info) {
|
||||
memory: `${judge.memoryLimit}m`,
|
||||
};
|
||||
if (judge.extraSourceFiles) {
|
||||
const user_extra_files = [];
|
||||
const files = [];
|
||||
for (const key in judge.extraSourceFiles) {
|
||||
for (const file in judge.extraSourceFiles[key]) {
|
||||
user_extra_files.push(file);
|
||||
files.push(file);
|
||||
}
|
||||
}
|
||||
config.user_extra_files = user_extra_files;
|
||||
config.user_extra_files = files;
|
||||
}
|
||||
if (judge.checker?.type === 'custom') {
|
||||
config.checker_type = judge.checker.interface;
|
||||
|
||||
@@ -501,12 +501,12 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
|
||||
this.response.body.additional_file = getAdditionalFile ? sortFiles(this.pdoc.additional_file || []) : [];
|
||||
if (pjax) {
|
||||
const { testdata, additional_file } = this.response.body;
|
||||
const owner_udoc = await user.getById(domainId, this.pdoc.owner);
|
||||
const owner = await user.getById(domainId, this.pdoc.owner);
|
||||
this.response.body = {
|
||||
fragments: (await Promise.all([
|
||||
this.renderHTML('partials/problem_files-testdata.html', { testdata, pdoc: this.pdoc }),
|
||||
this.renderHTML('partials/problem_files-additional_file.html', { additional_file, pdoc: this.pdoc }),
|
||||
this.renderHTML('partials/problem-sidebar-information.html', { pdoc: this.pdoc, owner_udoc }),
|
||||
this.renderHTML('partials/problem-sidebar-information.html', { pdoc: this.pdoc, owner_udoc: owner }),
|
||||
])).map((i) => ({ html: i })),
|
||||
};
|
||||
this.response.template = '';
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
const _CACHE_INFO = {
|
||||
last_s: 0.0,
|
||||
last_y: 0,
|
||||
s: 0.0,
|
||||
y: 0,
|
||||
values: [0.0],
|
||||
};
|
||||
|
||||
function _LOGP(x: number) {
|
||||
const sqrt_2_pi = 2.506628274631000502415765284811; // Sqrt[Pi]
|
||||
return (2 * Math.exp(-1.0 * (Math.log(x) ** 2) * 2)) / x / sqrt_2_pi;
|
||||
const sqrtPi = 2.506628274631000502415765284811; // Sqrt[Pi]
|
||||
return (2 * Math.exp(-1.0 * (Math.log(x) ** 2) * 2)) / x / sqrtPi;
|
||||
}
|
||||
|
||||
function _integrate_ensure_cache(y: number) {
|
||||
let last_y = _CACHE_INFO.last_y;
|
||||
if (y <= last_y) return _CACHE_INFO;
|
||||
let s = _CACHE_INFO.last_s;
|
||||
function _intergrateEnsureCache(y: number) {
|
||||
let lastY = _CACHE_INFO.y;
|
||||
if (y <= lastY) return _CACHE_INFO;
|
||||
let s = _CACHE_INFO.s;
|
||||
const dx = 0.1;
|
||||
const dT = 2;
|
||||
let x0 = (last_y / dT) * dx;
|
||||
while (y > last_y) {
|
||||
let x0 = (lastY / dT) * dx;
|
||||
while (y > lastY) {
|
||||
x0 += dx;
|
||||
s += _LOGP(x0) * dx;
|
||||
for (let i = 1; i <= dT; i++) _CACHE_INFO.values.push(s);
|
||||
last_y += dT;
|
||||
lastY += dT;
|
||||
}
|
||||
_CACHE_INFO.last_y = last_y;
|
||||
_CACHE_INFO.last_s = s;
|
||||
_CACHE_INFO.y = lastY;
|
||||
_CACHE_INFO.s = s;
|
||||
return _CACHE_INFO;
|
||||
}
|
||||
|
||||
_integrate_ensure_cache(1000000);
|
||||
_intergrateEnsureCache(1000000);
|
||||
|
||||
function _integrate(y: number) {
|
||||
_integrate_ensure_cache(y);
|
||||
_intergrateEnsureCache(y);
|
||||
return _CACHE_INFO.values[y];
|
||||
}
|
||||
|
||||
function difficultyAlgorithm(nSubmit: number, nAccept: number) {
|
||||
if (!nSubmit) return null;
|
||||
const s = _integrate(nSubmit);
|
||||
const ac_rate = nAccept / nSubmit;
|
||||
const ans = Math.round(10.0 - 1.30 * s * 10.0 * ac_rate);
|
||||
const acRate = nAccept / nSubmit;
|
||||
const ans = Math.round(10.0 - 1.30 * s * 10.0 * acRate);
|
||||
return Math.max(ans, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,16 +103,16 @@ interface RatingOutputUser {
|
||||
}
|
||||
|
||||
function calculate(users: RatingInputUser[]): RatingOutputUser[] {
|
||||
let last_idx = 0;
|
||||
let last_rank = 1;
|
||||
let lastIdx = 0;
|
||||
let lastRank = 1;
|
||||
for (let i = 1; i < users.length; i++) {
|
||||
if (users[i].rank > last_rank) {
|
||||
for (let j = last_idx; j < i; j++) users[j].rank = i;
|
||||
last_idx = i;
|
||||
last_rank = users[i].rank;
|
||||
if (users[i].rank > lastRank) {
|
||||
for (let j = lastIdx; j < i; j++) users[j].rank = i;
|
||||
lastIdx = i;
|
||||
lastRank = users[i].rank;
|
||||
}
|
||||
}
|
||||
for (let i = last_idx; i < users.length; i++) {
|
||||
for (let i = lastIdx; i < users.length; i++) {
|
||||
users[i].rank = users.length;
|
||||
}
|
||||
const calculator = new RatingCalculator(users);
|
||||
|
||||
@@ -56,7 +56,8 @@ export async function feedback(): Promise<[string, StatusUpdate]> {
|
||||
superagent.post(`${system.get('server.center')}/report`)
|
||||
.send({ installId, payload })
|
||||
.then((res) => {
|
||||
if (res.body.updateUrl) system.set('server.center', res.body.updateUrl);
|
||||
if (res.body.updateUrl?.startsWith('https://')) system.set('server.center', res.body.updateUrl);
|
||||
if (res.body.notification) global.Hydro.model.message.sendNotification(res.body.notification);
|
||||
})
|
||||
.catch(() => logger.debug('Cannot connect to hydro center.'));
|
||||
return [mid, $update];
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
/* eslint-disable no-await-in-loop */
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import AdmZip from 'adm-zip';
|
||||
import yaml from 'js-yaml';
|
||||
import { pick } from 'lodash';
|
||||
|
||||
Reference in new issue
Block a user